I’ve got a class A defined in a separate header file. I want class B to have a reference to a object of class A stored as a variable.
Like this:
File: A.h
class A {
//Header for class A...
};
File: B.h
#include "A.h"
class B {
private:
(24) A &variableName;
public:
(36) B(A &varName);
};
When i try to compile it with g++ I get the following error:
B.h:24: error: ‘A’ does not name a type
B.h:36: error: expected `)' before ‘&’ token
Any suggestions on what I’m doing wrong? If it matters, the class A is an abstract class.
EDIT: Some typos in the code
By me it compiles fine (as expected). I’m guessing
A.hisn’t being included properly. Is there another file with the same name that gets included instead? Perhaps there are#ifdefs or some such that prevent the definition ofAfrom being seen by the compiler. To check this, I would put some sort of syntax error intoA.hand see if the compiler catches it.