选哪个??为什么?
*. 32位平台下,以下代码
class Base
{
public:
Base (){};
~ Base (){};
};
class CDemo
{
public:
CDemo() {}
virtual ~CDemo() {}
protected:
static int m_siObjCnt;
Base m_ob;
};
void main()
{
CDemo ob;
cout<<sizeof(ob)<<endl;
}
的输出是:( )
A) 4
B) 5
C) 8
D) 12
*. 下面关于C++的说法中,错误的是:( )
A) static用来修饰类的成员函数,可以不用实例化通过类名,直接调用该函数
B) const常常用来修饰函数参数、常量对象等,以防止其被改变,所以const变量的值不可能被改变
C) 标准C++中,一个类可以有多个父类
D) STL是C++标准的一部分
*. 下列运算符中不能被重载的是:( )
A) &&
B) !=
C) :?
D) ++
*. 有两个类的定义如下:
class Base
{
public:
virtual void f( int iParam){
cout << "Base::f(int)" << endl;
};
virtual void f( double dParam){
cout << "Base::f(double)" << endl;
};
virtual void g( int i = 10 ){
cout << i << endl;
};
};
class Derived: public Base
{
public:
void f( complex<double> Param){
cout << "Derived::f(complex)" << endl;
};
void g( int i = 20 ){
cout << "Derived::g() " << i << endl;
};
};
则下面的程序的输出结果为:( )
int main() {
Base b;
Derived d;
Base* pb = new Derived;
b.f(1.0);
d.f(1.0);
pb->f(1.0);
delete pb;
return 0;
}
A) Base::f(double)
Derived::f(complex)
Derived::f(complex)
B) Base::f(double)
Derived::f(complex)
Base::f(double)
C) Base::f(int)
Derived::f(complex)
Base::f(double)
D) Base::f(double)
Base::f(double)
Base::f(double)
*. 类的定义与上题相同,则下面的程序的输出结果为:( )
int main() {
Base b;
Derived d;
Base* pb = new Derived;
b.g();
d.g();
pb->g();
delete pb;
return 0;
}
A) 10
Derived::g() 20
Derived::g() 20
B) 10
10
Derived::g() 20
C) 10
Derived::g() 10
Derived::g() 10
D) 10
Derived::g() 20
Derived::g() 10