Untitled
unknown
plain_text
2 years ago
1.2 kB
35
Indexable
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;
class test{
int x, y, z;
public:
test(){
cout << "default contructor" << endl;
}
test(int x, int y, int z){
this->x = x;
this->y = y;
this->z = z;
}
//void operator /();
void operator -();
friend test operator << (test t1, test t2);
void showData();
};
void test :: showData(){
cout << "x = " << x << endl;
cout << "y = " << y << endl;
cout << "z = " << z << endl;
}
// void test :: operator/(){
// x = x / 2;
// y = y / 2;
// z = z / 2;
// }
void test :: operator-(){
x = -x;
y = -y;
z = -z;
}
test operator <<(test obj1, test obj2){
test obj3;
obj3.x = obj1.x * obj2.x;
obj3.y = obj1.y * obj2.y;
obj3.z = obj1.z * obj2.z;
return obj3;
}
int main(){
test t1(100, 200, 300), t2(1, 2, 3), t3;
-t1;
///t1;
t1.showData();
//t1/;
-t1;
t1.showData();
t3 = t1 << t2;
t3.showData();
//t1/;
-t1;
t1.showData();
}Editor is loading...