Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Inheritance.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// C++ program to demonstrate implementation of Inheritance


#include <bits/stdc++.h>
using namespace std;

//Base class
class Parent
{
public:
int id_p;
};

// Sub class inheriting from Base Class(Parent)
class Child : public Parent
{
public:
int id_c;
};

//main function
int main()
{

Child obj1;

// An object of class child has all data members
// and member functions of class parent
obj1.id_c = 7;
obj1.id_p = 91;
cout << "Child id is " << obj1.id_c << endl;
cout << "Parent id is " << obj1.id_p << endl;

return 0;
}