Practical 20
#include<iostream>
using namespace std;
class space
{
int a,b,c;
public:
void setdata(int x,int y,int z)
{
a=x;
b=y;
c=z;
}
void display()
{
cout<< a <<" ";
cout<< b <<" ";
cout<< c <<endl;
}
void operator-();
};
void space::operator-()
{
a=-a;
b=-b;
c=-c;
}
int main()
{
space s;
s.setdata(10,-20,73);
cout<<"S : ";
s.display();
-s;
cout<<"S : ";
s.display();
return 0;
}
output:
S:
10 -20 73
S:
-10 20 -73
using namespace std;
class space
{
int a,b,c;
public:
void setdata(int x,int y,int z)
{
a=x;
b=y;
c=z;
}
void display()
{
cout<< a <<" ";
cout<< b <<" ";
cout<< c <<endl;
}
void operator-();
};
void space::operator-()
{
a=-a;
b=-b;
c=-c;
}
int main()
{
space s;
s.setdata(10,-20,73);
cout<<"S : ";
s.display();
-s;
cout<<"S : ";
s.display();
return 0;
}
output:
S:
10 -20 73
S:
-10 20 -73
No comments:
Post a Comment