Program -
#include<iostream.h>
#include<conio.h>
class abc
{
private:
int a;
float b;
public:
abc(int,float);
void display();
};
abc::abc(int
x,float y)
{
a=x;
b=y;
}
void
abc::display()
{
cout<<"integer
value is:"<<a<<"\n";
cout<<"float
value is:"<<b<<"\n";
}
void main()
{
clrscr();
abc m1(20,33.3);
abc m2(10,5.5);
cout<<"first
object has value"<<"\n";
m1.display();
cout<<"second
object has value"<<"\n";
m2.display();
getch();
}
Output -
first object has
value
integer value
is:20
float value
is:33.299999
second object has
value
integer value
is:10
float value is:5.5
0 comments:
Post a Comment