

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The rules for constructor calling in inheritance in c++, including the default constructor of the base class, calling a parametrized constructor of the base class, private members of the base class in the derived class constructor, copy constructor by reference, private constructor, and virtual base class. Examples are provided for each concept.
What you will learn
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!
Yes constructor can be declared as private, but we cannot create the object directly. It can be done using static functions Example: class Test { int x,y; Test(int a, int b) { x=a; y=b; } public: static Test * CreateObject() // this function will create an object. { Test t=new Test(10,10); return t; } }; int main() { Test *t=Test::CeateObject(); } Virtual Base class I multiple-path inheritance, a derived class may get the duplicate features via multiple parent classes. To avoid duplicacy we make parent class as virtual