.
Home About-us Privacy Policy Contact-us Services

Thursday, October 8, 2015

C++ Program of single inheritance

ad+1

Program - 


#include<iostream.h>
#include<conio.h>
class abc
{
char name[20];
public:
void input()
{
cout<<"enter name==>";
cin>>name;
}
void print()
{
cout<<"name is"<<name<<endl;
}
};
class ba:private abc
{
int rollno;
public:
void getdata()
{
input();
cout<<"enter rollno==>";
cin>>rollno;
}
void putdata()
{
print();
cout<<"rollno is==>"<<rollno;
}
};
void main()
{
clrscr();
ba a;
a.getdata();
a.putdata();
getch();
}

Output -
 

enter name==>anu
enter rollno==>23
name is anu
rollno is==>23

0 comments:

Post a Comment

Home About-us Privacy Policy Contact-us Services
Copyright © 2014 All Programs Examples | All Rights Reserved. Blogger Templates Download Blogger Templates