Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

inheritance in c++

// C++ program to explain
// Single inheritance
#include<iostream>
using namespace std;
 
// base class
class Vehicle {
  public:
    Vehicle()
    {
      cout << "This is a Vehicle
";
    }
};
 
// sub class derived from a single base classes
class Car : public Vehicle {
 
};
 
// main function
int main()
{  
    // Creating object of sub class will
    // invoke the constructor of base classes
    Car obj;
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #inheritance
ADD COMMENT
Topic
Name
4+4 =