source file name: optor4.cpp
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<math.h>
class Sigma
{
int x,y,z;
public:
void getdata(int a, int b,int c)
{
x=a;
y=b;
z=c;
}
void show()
{
cout<<" "<<x <<" "<<y <<" "<<z<<endl;
}
void operator/(int b)
{
x=x/b;
y=y/b;
z=z/b;
}
};
void main()
{
int b;
clrscr();
cout<<"Operator overloading program: ";
Sigma S;
S.getdata(10,20,30);
cout<< "\n S= ";
S.show();
cout<<" enter divided no";
cin>>b;
S/b;
cout<<"\n after applying operator(/) function values divided by: "<<b;
cout<< "\n S= ";
S.show();
getch();
}
output:
Operator overloading program
S=10 20 30
enter divided no 5
after applying operator(/) function values divided by: 5
S= 2 4 6
0 Comments
Post a Comment