${func(1)}
${foo:func(4)}
${func:foo(2)}
${foo(5):func}
${func:foo(“easy”)}
${func:foo(“3”).name}
第1题:
有如下程序#include <iostream>using namespace std;class A{public:virtual void func1 (){ cout<<"A1"; }void func2(){ cout<<"A2"; }};class B: public A{public:void func l(){ cout<<"B1"; }void func2(){ cout<<"B2"; }};int main() {A *p=new B;p->func1();p->func2();return 0;}运行此程序,屏幕上将显示输出( )。
A.B1B2
B.A1A2
C.B1A2
D.A1B2
第2题:
A.int foo() { /* more code here */ }
B.void foo() { /* more code here */ }
C.public void foo() { /* more code here */ }
D.private void foo() { /* more code here */ }
E.protected void foo() { /* more code here */ }
第3题:
对于类定义
class A{
public:
virtual void func1( ) {}
void func2( ) {}
};
class B: public A{
public:
void func1( ) {cout < < "class B func 1" < < endl;}
virtua1 void func2( ) {cout < < "class B func 2" < < endl;}
};
下面正确的叙述是
A.A: :func2( ) 和B: :func1( ) 都是虚函数
B.A: :func2( ) 和B: :func1( ) 都不是虚函数
C.B: :func1( ) 是虚函数,而A: :func2( ) 不是虚函数
D.B: :func1( ) 不是虚函数,而A: :func2( ) 是虚函数
第4题:
有如下程序: #include<iostream> using namespace std; class A{ public: virtual void func1(){cout<<"A1";} void func2(){cout<<"A2";} }; class B:public A{ public: void func1(){cout<<"B1";} void func2(){cout<<"B2";} }; int main() { A *p=new B; p->func1(); p->func2(); return 0; } 执行该程序,屏幕上将显示输出( )。
A.B1B2
B.A1A2
C.B1A2
D.A1B2
第5题:
下列程序写法不正确的是( )。
A.func1(){…func2(){…}…}
B.func1(){…}func2(){…}
C.func2();func1(){…func2();…}func2(){…}
D.func1(){…func1();…}
第6题:
A.${func(1)}
B.${foo:func(4)}
C.${func:foo(2)}
D.${foo(5):func}
E.${func:foo("easy")}
F.${func:foo("3").name}
第7题:
下面程序执行后的结果是( )。 #include<iostream> using namespace std; void func1(int i); void func2(int i); char st[]="hello, friend!"; void func1(int i) { cout<<st[i]; if(i<3){i+=2;func2(i);} } void func2(int i) { cout<<st[i]; if(i<3){i+=2;func1(i);} } void main() { int i=0;func1(i);cout<<endl;}
A.ello
B.hel
C.hlo
D.him
第8题:
A.${func(1)}
B.${foo:func(4)}
C.${func:foo(2)}
D.${foo(5):func}
E.${func:foo(“easy”)}
F.${func:foo(“3”).name}
第9题:
int func1(int& b)
{
return 0;
}
void func2()
{
int bbb = 3;
func1(&bbb);
func1(bbb);
}
func2中有何错误,func1的参数b 的类型是什么。
第10题:
有如下函数模板的定义: template <class T> T func(Tx,Ty){ return x*x+y*y;}
A.func(3,5);
B.func<>(3,5);
C.func(3,5.5);
D.func<int> (3,5.5);