C++ Basic

State a runtime polymorphism example program in C++

Answer includes runtime polymorphism example program in C++ OOPs and about virtual and pure virtual function in C++. Example of run time polymorphism in C++ object oriented programming is function overriding where functions get resolved at run time i.e. when we execute the application. This is different than compile time polymorphism where function gets resolved […]

What is default constructor in C++? – Availability Discussion

Default constructor in C++ is provided by the compiler if we don’t implement any constructor in the class. For example, in below class, we don’t have any constructor implemented. Hence, once we create an object of the class then default constructor is called in C++ program provided by the compiler internally. NOTES: People also refer […]

Can static function access non static variables in C++?

No, Static function of a class in C++ cannot access non-static variables, but, it can access static variable only. However, non-static member function can access static and non-static variable both. Static function is not associated with class object, means without object using class name only it can be called. whereas non-static variables are associated with […]

Which is called first constructor or overloaded new operator in C++?

Interview Question: A C++ class has constructor and overloaded new and delete operator function. If we create a class object dynamically using new then out of constructor and overloaded new operator function, which one get called first? Recommended to read a simple program with important important points of new and delete operator overloading in C++ […]

What is constructor overloading in C++ – Short and Easy

Constructor overloading in C++ programming is same as function overloading. When we create more that one constructors in a class with different number of parameters or different types of parameters or different order of parameters, it is called as constructor overloading. In sample words, writing multiple constructors in a class is known as constructor overloading […]

What is mutable keyword in C++?

The mutable keyword in C++ before any data member of a class allows constant functions to modify it. You know that inside a const member function in c++ , a class member variable cannot be changed. For example, In the below class, if you try to modify the carID variable inside the const function “int […]

Scroll to top