题目内容
写出程序运行结果:_________using namespace std;class Vector{ public: Vector(){ } Vector(int i,int j) { x = i ; y = j ; } friend Vector operator+ ( Vector v1, Vector v2 ) { Vector tempVector ;tempVector.x = v1.x + v2.x ;tempVector.y = v1.y + v2.y ;return tempVector ; } void display() { cout << "( " << x << ", " << y << ") "<< endl ; }private: int x , y ;};int main(){ Vector v1( 1, 2 ), v2( 3, 4 ), v3 ; cout << "v1 = " ; v1.display() ; cout << "v2 = " ; v2.display() ; v3 = v1 + v2 ; cout << "v3 = v1 + v2 = " ; v3.display() ;}
查看答案
搜索结果不匹配?点我反馈
更多问题