标签:函数参数 调用 space his font style mes name stream
1 #include <iostream> 2 #include <string> 3 using namespace std; 4 class Test 5 { 6 int value; 7 public: 8 Test(int _value) 9 { 10 this->value = _value; 11 } 12 ~Test() 13 { 14 } 15 int get_value() 16 { 17 return this->value; 18 } 19 }; 20 //重载逻辑与操作符 21 bool operator && (Test op1,Test op2) 22 { 23 return op1.get_value() && op2.get_value(); 24 } 25 //重载逻辑或操作符 26 bool operator || (Test op1,Test op2) 27 { 28 return op1.get_value() || op2.get_value(); 29 } 30 Test func(Test t) 31 { 32 cout << "Test func(Test t) : Test.value = " << t.get_value() << endl ; 33 34 return t; 35 } 36 int main() 37 { 38 Test t0(0); 39 Test t1(1); 40 #if 0 41 if (func(t0) && func(t1)) 42 { 43 cout << "The result is true" << endl; 44 } 45 else 46 { 47 cout << "The result is false" << endl; 48 } 49 #endif 50 if (operator &&(func(t0),func(t1))) 51 { 52 cout << "The result is true" << endl; 53 } 54 else 55 { 56 cout << "The result is false" << endl; 57 } 58 }
运行结果:
标签:函数参数 调用 space his font style mes name stream
原文地址:https://www.cnblogs.com/chengeputongren/p/12235583.html