题目内容

写出程序运行结果:_______#include class A { int a;public: void f( int a ) { cout<< a << endl; } void g( ) { cout<< "g( )" << endl; }};class B: public A{public: void h( ) {cout<< "h( )" << endl; }};void main( ){ B objb; objb.f(5); objb.g( ); objb.h( );}

查看答案
更多问题

写出程序运行结果:____________#include class B{public: B( ) {cout<<"CONS_B"<

写出程序运行结果:_________#include class A{protected: int ia;public: A(int j) {ia=j;cout<<"A"<

写出程序运行结果:_________#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;}int 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 = "<

写出程序运行结果:_________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() ;}

答案查题题库