.
Home About-us Privacy Policy Contact-us Services

Friday, October 9, 2015

C++ Program of assignment operator overloading

ad+1

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

Home About-us Privacy Policy Contact-us Services
Copyright © 2014 All Programs Examples | All Rights Reserved. Blogger Templates Download Blogger Templates