Search This Blog

Tuesday, 13 November 2012

Passing arguments to base class constructor

#include<iostream.h>
#include<conio.h>
class student
{
int rlno;
public:
student(){cout<<"Base Constructor\n";}
student(int r){rlno=r;}
void getData()
{
cout<<"Get Roll Number";
cin>>rlno;
}
void putData()
{
cout<<"Roll Number="<<rlno<<"\n";
}
~student(){cout<<"Base Destructor\n"}
};
class mark:public student
{
int m;
public:
mark(){cout<<"Derived Constructor\n";}
mark(int x){m=x;}
mark(int x,int y):student(x)
{m=y;}
void getData()
{
cout<<"Get Mark";

cin>>m;
}
void putMark()
{
cout<<"Mark="<<m<<"\n";
}
~mark()
{
cout<<"Derived Destructor\n";
}
};
void main()
{
clrscr();
mark M(456,90);
getch();
}


No comments:

Post a Comment