Write a program to implement the concept of parameterized constructor

#include
#include
class trial
{
private:
int age;
float wt;
public:
void getdata();
void display();
trial(int);
trial(int,float);
trial()
{
}
};
void trial::getdata()
{
cout<>age;
cout<>wt;
}
void trial::display()
{
cout<<"n The Age of Student Was:"<<age;
cout<<"n The Weight of Student Was:"<<wt;
}
trial::trial(int t)
{
age=t;
}
trial::trial(int p,float q)
{
age=p;
wt=q;
}
main()
{
class trial x(16),y(17,48.5),z(18,52.7),a,b;
clrscr();

x.display();
y.display();
z.display();
getch();
cout<<"nn";
a.getdata();
a.display();
cout<<"nn";
b.getdata();
b.display();
getch();
}

Leave a reply