diff --git a/Inheritance.cpp b/Inheritance.cpp new file mode 100644 index 0000000..fc02333 --- /dev/null +++ b/Inheritance.cpp @@ -0,0 +1,36 @@ +// C++ program to demonstrate implementation of Inheritance + + +#include +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; +} +