I have myclassA
and myClassB
. I want to pass a ClassA
object into ClassB
's constructor. therefore I include A
's header into B
and B's header into A
, but I get this error
'myclassB' does not name a type
Here is the code that I simplified:
myclassa.h
#ifndef XMLHANDLER_H
#define XMLHANDLER_H
#include "mainwindow.h"
#include "myclassb.h"
class myclassA{
public:
myclassA();
private:
myclassB *mb;
};
#endif // XMLHANDLER_H
myclassb.h
#ifndef CLASSB_H
#define CLASSB_H
#include "myclassa.h"
class myclassB{
public:
myclassB(myclassA *newclass);
~myclassB();
};
#endif // CLASSB_H
myclassa.cpp
#include "myclassa.h"
myclassA::myclassA(){}
myclassb.cpp
#include "myclassb.h"
myclassB::myclassB(myclassA *newclass)
{
//do something
}
How can I fix the error?