Thursday 12 February 2015

C++ Program to pass arguments for 2 object using constructor

C++ Program to pass arguments for 2 object using constructor 
#include<iostream.h>
#include<conio.h>
class integer
{
int a,b;
public:
integer(int,int);
void display()
{
cout<<"\n"<<""<<a;
cout<<"\t"<<b;
}
};
integer::integer(int x,int y)
{
a=x;
b=y;
}
void main()
{
clrscr();
integer int1(20,25);
cout<<"object1";
int1.display();
integer int2(30,20);
cout<<"\n object2";
int2.display();
getch();
}

No comments:

Post a Comment