It is my understanding that in C++ objects of derived classes invoke the derived class' constructor but before the body is executed the base class' constructor is invoked and takes effect and then the derived class' constructor's body is executed. If this knowledge is correct, then what happens if the base class' constructor initializes a private variable of the base class that would not be inherited to the derived class, when a new objecct of the derived class is declared.
CPPRULZ 0 Junior Poster in Training
Recommended Answers
Jump to PostIt is my understanding that in C++ objects of derived classes invoke the derived class' constructor but before the body is executed the base class' constructor is invoked and takes effect and then the derived class' constructor's body is executed. If this knowledge is correct, then what happens if the …
Jump to PostWell when a derived object is declared then the derived class inherits the public and protected variables and functions, not the private variables or functions of the base class. I was wondering what would happen if the constructor of the base class(which is inherited always) initializes some of those private …
All 7 Replies
Intrade 33 Junior Poster
ArkM 1,090 Postaholic
CPPRULZ 0 Junior Poster in Training
Intrade 33 Junior Poster
ArkM 1,090 Postaholic
CPPRULZ 0 Junior Poster in Training
ArkM 1,090 Postaholic
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.