Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Endure order of construction?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Rune Allnor, post: 3950363"] 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 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Endure order of construction?
Top