Foo.h
class Foo{
private:
void printSpecialBar(Bar b);//syntax error: Identifier Bar
Foo.cpp
#include "Bar.h"
void Foo::printSpecialBar(Bar b)
{
//code goes here
}
Bar has the default constructor and one that takes two int's.
What is the problem with the syntax error? I tried using the scope resuloution operator Bar::Bar b but it didn't fix it.
Bar.hinFoo.hBarinside one ofFoo's member function declarations, you must tell the compiler what it is. Otherwise, the compiler thinks that you made a typo. Forward-declaringBarwithclass Bar;would give compiler enough information to compile your program, as long as the declaration precedes the point whereBaris first used.