R
Rune Allnor
Hi all.
I have this class that contain a number of instances of other classes:
class A {...};
class B {...};
class Spider {
public:
Spider(const *A, const *B);
private:
Spider(){};
};
class BigClass{
public:
BigClass() : A_(), B_()
{
Spider_(&A_,&B_);
}
private:
A A_;
B B_;
Spider Spider_;
};
The A and B classes contain data, while the Spider class
is supposed to maintain certain connections / relations
between the two collections of data.
The problem here is the constructor of BigClass: Both A_ and
B_ have to be fully constructed before the constructor of Spider_
can start. Even if the declarations above indicate that it is
sufficient that the adresses of A_ and B_ have been determined
at the point when Spider::Spider(...) is called, the operations
inside
Spider::Spider(...) requires that A_ and B_ have been fully
constructed.
Is there any way to ensure that things happen in the required
sequence?
Rune
I have this class that contain a number of instances of other classes:
class A {...};
class B {...};
class Spider {
public:
Spider(const *A, const *B);
private:
Spider(){};
};
class BigClass{
public:
BigClass() : A_(), B_()
{
Spider_(&A_,&B_);
}
private:
A A_;
B B_;
Spider Spider_;
};
The A and B classes contain data, while the Spider class
is supposed to maintain certain connections / relations
between the two collections of data.
The problem here is the constructor of BigClass: Both A_ and
B_ have to be fully constructed before the constructor of Spider_
can start. Even if the declarations above indicate that it is
sufficient that the adresses of A_ and B_ have been determined
at the point when Spider::Spider(...) is called, the operations
inside
Spider::Spider(...) requires that A_ and B_ have been fully
constructed.
Is there any way to ensure that things happen in the required
sequence?
Rune