Typecasting a class pointer
I've got a code that is the following way:
classes.h
class claseA {
public:
claseA();
~claseA();
};
class claseB {
public:
claseB();
claseB( const claseA& aClase);
~claseB();
};
main.cpp
#include "classes.h"
int main () {
claseA* pClaseA = new claseA();
claseB* pClaseB = new claseB( pClaseA* ); // compiler error
.....
return 0;
};
I get a "expected primary-expression before ')'" error at the marked
line. Seems that try pass a class using a pointer is not valid but when
I try to typecast the dereferenced pointer this way:
classB* pClaseB = new claseB( (claseA)pClaseA* );
I get a different compiler error: "no matching function call to
'claseA::claseA(claseA*&)'
In case this compiler error is a precedence error I tried too the
following code line:
classB* pClaseB = new claseB( (claseA)(pClaseA*) );
but I get again the first compiler error: expected primary-expression
before ')'
Is clear that I'm missing something, or is just that cannot be done this
way?