Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- class Geeks
- {
- public:
- int i;
- string name;
- // Default constructor
- Geeks()
- {
- i = -1;
- }
- // Parametrized constructor
- Geeks(int num)
- {
- i = num;
- }
- //inside class definition of method
- void print_name()
- {
- cout << name;
- }
- };
- //class a derived from parent class b and c
- //class a : public b, public c
- //outside class definition of method
- void Geeks::print_number()
- {
- cout << i;
- }
- //Henlo inherits the class Geeks. Henlo is child while Geeks is parent.
- class Henlo : public Geeks
- {
- };
- int main()
- {
- Geeks g;
- cout << g.print_name() << endl;
- cout << g.name();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement