source file name: singleinh.cpp
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class A
{
public:
void sqcube(int n)
{
int s=n*n;
int c=n*n*n;
cout<<"\n square: "<<s<<" cube: "<<c;
}
} ;
class B: public A
{
public:
void table(int n)
{
int i;
cout<< "\n table of "<<n;
for(i=1;i<=10;i++)
{
cout<< i*n<<" ";
}
}
};
void main()
{
clrscr();
cout<<"Single Inheriatnce program: ";
B ob;
ob.sqcube(5);
ob.table(7);
getch();
}
output:
0 Comments
Post a Comment