C)void fun(double a, int B); D)bool fun(int a, double b = 0.0); (22)有如下程序: #include
using namespace std; class Sample{ public:
Sample(){}
~Sample(){cout<<'*';} };
int main(){
Sample temp[2], *pTemp[2]; return 0; }
执行这个程序输出星号(*)的个数为( )。 A)1 B)2 C)3 D)4
(23)下列选项中,与实现运行时多态性无关的是( )。 A)重载函数 B)虚函数 C)指针 D)引用
(24)下列运算符函数中,肯定不属于类 Value 的成员函数的是( )。 A)Value operator+(Value); C)Value operator*(int);
B)Value operator-(Value, Value); D)Value operator/(Value);
(25)下列模板声明中,有语法错误的是( )。 A)templateT fun(T x){return x;}
B)templateT fun(T x, int n){return x*n;} C)templateT fun(T *p){return *p;} D)templateT classA{T n;};
(26)在语句“cout<<'A';”中,cout 是( )。 A)类名 C)函数名
(27)有如下程序: #include
using namespace std; class MyClass{ public:
MyClass(int i=0){cout<<1;}
MyClass(const MyClass&x){cout<<2;} B)对象名
D)C++的关键字
MyClass& operator=(const MyClass&x){cout<<3; return*this;} ~MyClass(){cout<<4;} };
int main(){
MyClass obj1(1),obj2(2),obj3(obj1); return 0: }
运行时的输出结果是( )。
A)112444 B)11114444 C)121444 D)11314444 (28)有如下程序: #include
using namespace std;