更多"若有以下程序: #include <iost ream> usin"的相关试题:
[单项选择]有如下程序:
#include<iost earn>
using namespace std;
class TestClass
protected:
TestClass( )cout<<’x’;
TestClass(char C) cout<<c;
;
class TestClass1:public TestClass
public:
TestClass1(char C) Cout<<c;)
;
int main( )
TestClass1 d1(’y’);
return 0;
执行这个程序,屏幕上将显示输出( )。
A. y
B. yx
C. xy
D. yy
[单项选择]若有以下程序 #include <iostream> using namespace std; class A { public: A(int i,int j) { a=i; b=j; } void move(int x, int y) { a+=x; b+=y; } void show( ) { cout < <a < <" , " <<b<< end1; } private: int a,b; }; class B : private A { public: B(int i,int j) :A(i,j) {} void fun ( ) { move (3, 5); } void f1 ( ) { A::show( ); } }; int main ( ) { B d(3,4); d. fun ( ); d.f1( ); return 0; } 程序执行后的输出结果是 ( )。
A. 3,4
B. 6,8
C. 6,9
D. 4,3
[简答题]有如下程序
#include
#include
using namespace std;
class MyClass{
public:
MyClass( ){cout<<’A”;}
MyClass(char c {cout<A. A.ABX
B.ABXB
C.AXB
D.AXBB
[单项选择]有如下程序:
#include
#include
using namespace std;
class MyString{
public;
char str[80];
MyString(const char*s) {strcpy(str,s);}
MyString&operator+=(MyString a){
strcat(str,a.str);
return*this;
}
};
ostream&operator<<(ostream&s,const MyString&z){return s << z.str}
int main( ){
MyString x("abc"),y("cde");
cout<<(x+=y)<A. abc
B. cde
C. abcde
D. abccde