题目内容

写出下列程序的执行结果是:__________________。#include #includeusing namespace std;class s{ public: s(){ *str = '\0'; } s( char *pstr ) { strcpy( str,pstr ); } char *gets() { return str; } s operator+( s obj );private: char str[10]; };s s::operator+( s obj ){ strcat( str,obj.str );return str; //或return *this } void main(){ s obj1( "Visual"),obj2("C++"),obj3; obj3 = obj1 + obj2; cout << obj3.gets() << endl;}

查看答案
更多问题

写出下列程序的执行结果是:__________________。#include 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 << "," <

写出下列程序的执行结果是:__________________。#include using namespace std;class T{ public : T() { a = 0; b = 0; c = 0; } T( int i, int j, int k ) { a = i; b =j; c = k; } void get( int &i, int &j, int &k ) { i = a; j = b; k = c; } T operator* ( T obj );private: int a , b , c;};T T::operator* ( T obj ){ T tempobj; tempobj.a = a * obj.a; tempobj.b = b * obj.b; tempobj.c = c * obj.c; return tempobj;}void main(){ T obj1( 1,2,3 ), obj2( 5,5,5 ), obj3; int a , b , c; obj3 = obj1 * obj2; obj3.get( a, b, c ); cout<<"(obj1*obj2):"<<"a="<

下面程序的运行结果如下: B::display() C::display() 在下划线处填上缺少的部分。源程序如下:#includeusing namespace std;class B{public: _________________ void display( ) {cout << "B::display( ) "<display();}void main(){ B b,*pb; C c; pb=&b; fun(pb); pb=&c; fun(pb);}

在下划线处填上缺少的部分。#include#includeusing namespace std;class complex{public:int real;int imag;complex(int r=0,int i=0){real=r;imag=i;}};complex operator+( ________________________,complex& b){int r=a.real+b.real;int i=a.imag+b.imag;return complex(r,i);}void main( ){complex x(1,2),y(3,4),z;z=x+y;cout<

答案查题题库