Home » » Operator overloading in C++ Programming

Operator overloading in C++ Programming

Operator overloading in C++ Programming

Operator overloading in C++ Programming


Operator overloading

#include<iostream.h>
#include<conio.h>
class distance
{
int feet;
float inch;
public:
distance(int f,float i);
void operator ++(void);
void display();
};
distance::distance(int f,float i)
{
feet=f;
inch=i;
}
void display::display()
{
cout<<"Distance in feet"<<feet<<endl;
cout<<"Distance in inch"<<inch<<endl;
}
void distance::operator ++(void)
{
feet ++;
inch ++;
}
void main()
{
clrscr();
distance dist(10,10);
++dist;
dist.display();
getch();
}


0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g