class A
{
public:
A(A*);
};
class B : public A
{
public:
B(A* a) : A(a) {}
};
class C : public B
{
private:
std::vector<B*>b_vec;
public:
C() : B() {}
void AddA(A* a)
{
B* b = new B(a);
b_vec.push_back(b);
}
};
How do I write the constructor code for A::A(A* a)? My BC5.02 gives me a "cannot assign to 'this'" error if I write:
A::A(A* a)
{
this = a;
}
and suggests something like this = malloc(n). This is something I can't understand. I mean, if I write this = (A)malloc(sizeof(*a)); or something it gives me an error explaining that there's no A::A(void*) constructor defined, which is true.
What would the correct syntax in this case be like?
Thanks in advance,
Crispy
edit: darn html....
[edited by - crispy on May 30, 2002 5:33:09 PM]