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
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
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.
vivekarora,
Welcome to the Daniweb.
>Is it possible to invoke ....
Answer is No.
Read this article - The ABCs of Writing C++ Classes
Constructors, Destructors, and Assignment Operators.
SUMMARY: Do I need a copy constructor? Are default arguments necessary in my constructors? How do I provide type conversion for my class? Do I need an equality operator?QUOTE]
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.