Hello Friends,

Can you pls. help me in below?
1) Is it possible to invoke derived class constructor from base class constructor some how in C++?
2) If yes, how?

Regards,
Vivek

Recommended Answers

All 3 Replies

No -- derived class has not been constructed at that point. When an object is instantiated the compiler first calls the base class then all derived classes, working its way up from the bottom to the top of the hierarchy. classes are destroy in the opposite manner.

Thank you friends. I agree with you in normal C++ usage. I was wondering if i could some how achieve this e.g. if i know the compiler internal working;).
Anyways, from your point, i understand there is no known way till now to achieve this. So thanks for your valuable comments.

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.