B
babakandme
Hi to every body...
I'm a novice C++ programmer & I've a question,
I have the ClassA & in it's constructor, I instantiate ClassB, and I
want send "this" pointer """pointer to ClassA""" to the ClassB.
But I get this Error from the compiler: and it's in ClassB...
Error from the compiler:
error C2061: syntax error : identifier 'TestA'
error C2143: syntax error : missing ';' before '*'
error C2501: 'TestA' : missing storage-class or type specifiers
error C2501: 'tA' : missing storage-class or type specifiers
//===========================================================
// TestA.cpp
#include"TestA.h"
#include"TestB.h"
class TestA
{
public:
TestA(){ tB = new TestB; }
~TestA(){ delete tB; }
void ShowSomething(){ cout << "Here is TestA..." << endl; }
private:
TestB * tB;
};
//===========================================================
// TestB.cpp
#include"TestB.h"
#include"TestA.h"
class TestB
{
public:
TestB();
~TestB();
void DoIt( TestA* aP ){ aP->ShowSomething(); } // >>>>>> Here is the
error
private:
TestA * tA;
};
//===========================================================
// Main.cpp
#include"TestB.h"
#include"TestA.h"
int main (int argc, char * argv)
{
TestA * aP = new TestA;
aP->CallTestB();
delete aP;
return 0;
}
I'm a novice C++ programmer & I've a question,
I have the ClassA & in it's constructor, I instantiate ClassB, and I
want send "this" pointer """pointer to ClassA""" to the ClassB.
But I get this Error from the compiler: and it's in ClassB...
Error from the compiler:
error C2061: syntax error : identifier 'TestA'
error C2143: syntax error : missing ';' before '*'
error C2501: 'TestA' : missing storage-class or type specifiers
error C2501: 'tA' : missing storage-class or type specifiers
//===========================================================
// TestA.cpp
#include"TestA.h"
#include"TestB.h"
class TestA
{
public:
TestA(){ tB = new TestB; }
~TestA(){ delete tB; }
void ShowSomething(){ cout << "Here is TestA..." << endl; }
private:
TestB * tB;
};
//===========================================================
// TestB.cpp
#include"TestB.h"
#include"TestA.h"
class TestB
{
public:
TestB();
~TestB();
void DoIt( TestA* aP ){ aP->ShowSomething(); } // >>>>>> Here is the
error
private:
TestA * tA;
};
//===========================================================
// Main.cpp
#include"TestB.h"
#include"TestA.h"
int main (int argc, char * argv)
{
TestA * aP = new TestA;
aP->CallTestB();
delete aP;
return 0;
}