Subscribe:

Labels

Tuesday, March 23, 2010

simple Inheritance

#include<iostream.h>

#include<conio.h>

class a

{

public:

int a;

a(){a=10;}

void disp()

{

cout<<a<<endl;

}

};

class b:a

{

public:

int b;

b(){b=30;}

void disp()

{

cout<<a<<endl<<b;

}

};

void main()

{

b obj;

clrscr();

obj.disp();

getch();

}

No comments:

Post a Comment