I have two classes. Class A contains a pointer to an instance of class B. In class A, I would like to call class B's instance method and send class A itself as the argument. I wrote the following code but it doesn't compile:
Source for Class A:
//a.h
#ifndef A_H
#define A_H
#include "b.h"
class A{
friend class B;
int i;
B *b;
public:
void callB(){b->calledByA(this);}
};
#endif
Source for Class B:
#ifndef B_H
#define B_H
#include "a.h"
class B{
int j;
public:
void calledByA(A* a){
//j=a.i;
}
};
#endif
The error given by VS 2010 is
error C2061: syntax error : identifier 'A'
error C2660: 'B::calledByA' : function does not take 1 arguments
Why?