Skip to content

Tag Archives: C++-Inheritance

Base Class: A base class is a class in Object-Oriented Programming language, from which other classes are derived. The class which inherits the base class… Read More
C++ allows users to use the concept of Run-Time Polymorphism using Virtual Functions for any type of Inheritance . Below is how to implement Run-Time… Read More
When a base class is derived by a derived class with the help of inheritance, the accessibility of base class by the derived class is… Read More
Virtual base classes are used in virtual inheritance in a way of preventing multiple “instances” of a given class appearing in an inheritance hierarchy when… Read More
We can create an object of one class into another and that object will be a member of the class. This type of relationship between… Read More
Object oriented design started right from the moment computers were invented. Programming was there, and programming approaches came into the picture. Programming is basically giving… Read More
Consider the below C++ program. #include<iostream> using namespace std; class A { public:      A(){ cout <<"1";}      A(const A &obj){ cout <<"2";} };    class B:… Read More
#include<iostream> using namespace std;    class Base1 { public:     char c; };    class Base2 { public:     int c; };    class Derived: public Base1,… Read More
#include<iostream> using namespace std;    class Base { protected:     int a; public:     Base() {a = 0;} };    class Derived1:  public Base { public:     int… Read More
#include<iostream> using namespace std;    class Base { public :     int x, y; public:     Base(int i, int j){ x = i; y = j; }… Read More
Output of following program? #include <iostream> #include<string> using namespace std;    class Base { public:     virtual string print() const     {         return "This is Base class";… Read More
#include<iostream> using namespace std;    class Base { public:     void fun()          {    cout << "Base::fun() called";     }     void fun(int i)     {   cout << "Base::fun(int i)… Read More
#include<iostream> using namespace std;    class Base { public:     int fun()  { cout << "Base::fun() called"; }     int fun(int i)  { cout << "Base::fun(int i)… Read More
#include<iostream> using namespace std;    class Base { public:     void show()     {         cout<<" In Base ";     } };    class Derived: public Base { public:… Read More
#include<iostream> using namespace std;    class Base {};    class Derived: public Base {};    int main() {     Base *bp = new Derived;     Derived *dp… Read More