mahdinegindar
پنج شنبه 16 دی 1389, 11:45 صبح
#include <iostream.h>
#include <conio.h>
class base{
int i,j;
public:
void set(int a,int b){i=a; j=b; }
void show(){
cout<<"i= "<<i<<" ,j= "<<j<<endl;
};
//****************************
class derived: public base{
int k;
public:
derived(int x){k=x;}
void showk() {cout<<"k= " <<k<<endl; }
};
//******************
int main()
{
derived ob(3);
ob.set(1,2);
ob.show();
ob.showk();
getch();
return 0;
}
#include <conio.h>
class base{
int i,j;
public:
void set(int a,int b){i=a; j=b; }
void show(){
cout<<"i= "<<i<<" ,j= "<<j<<endl;
};
//****************************
class derived: public base{
int k;
public:
derived(int x){k=x;}
void showk() {cout<<"k= " <<k<<endl; }
};
//******************
int main()
{
derived ob(3);
ob.set(1,2);
ob.show();
ob.showk();
getch();
return 0;
}