Why is the constructor called from top to bottom rather than bottom to top ????
abhi74k
0
Newbie Poster
Recommended Answers
Jump to PostMind explaining, what exactly do you mean?
Jump to PostAssuming the question is about construction of an object in a class hierarchy, Edward has trouble answering questions that are answered easily by Ed's intuition. Why does it not make sense for the base parts of an object to be constructed before the derived parts?
Jump to PostWell the main problem with starting the construction of a class from the derived part up to the base is that any variables you are using that are in your base in a function in your derived class would be undefined. Assume this situation.
class A { …
All 9 Replies
mrnutty
761
Senior Poster
Radical Edward
301
Posting Pro
abhi74k
0
Newbie Poster
Bench
212
Posting Pro
abhi74k
0
Newbie Poster
NathanOliver
429
Veteran Poster
Featured Poster
Bench
212
Posting Pro
Bench
212
Posting Pro
abhi74k
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.