单选题虚函数支持多态调用,一个基类的指针可以指向派生类的对象,而且通过这样的指针调用虚函数时,被调用的是指针所指的实际对象的虚函数,而非虚函数不支持多态调用。有如下程序: #include <iostream> using namespaee std; class Base public: virtual void f( )cout<<"f0+"; void g( )cout<<"gO+"; ; class Derived:public Base public: void f( )cout<<"f+"; void g( )cout<<"g+"; ; int main( ) Derived d; Base*P=&d: p->f( );p->g( ); return 0; 程序的输出结果是 A) f+g+ B) f0+g+ C) f+g0+ D) f0+g0+
单选题在一个抽象类中,一定包含有______。
单选题对于一个类定义,编译器可能会自动生成的函数不包括
单选题在下面程序中,括号里应填( )。 #include <iostream> using namespace std; class A public: void fun( ) cout << "Hello" << endl; ; class B:: public A void fun( ) ( ) //调用基类的函数fun( ) tout << "HI" << endl; ;
单选题for(int x=0,y=0;!x||y<=5;y++,x=!x)语句执行的循环次数是( )。
单选题为类Matrix重载下列运算符时,只能作为Matrix类成员函数重载的运算符是{{U}} {{/U}}。
A. +
B. =
C. <<
D. ++
单选题有以下程序int f1(int x, int y) return x>y? x:y;int f2(int x, int y) return x>y? y:x;main() int a=4,b=3,c=5,d,e,f; d=f1(a,B) ;d=f1(d,C) ; e=f2(a,B) ;e=f2(e,C) ; f=a+b+c-d-e; cout<<d<<", "<<f<<", "<<e<<end1;执行后输出结果是
单选题下列关于模板的描述中,错误的是______。
单选题有如下程序:
#include<iostream>
using namespace std;
class XX{
int x;
public:
XX(int xx=0):x(xx){}
int getX(){return x;}
};
class YY:public XX{
int y;
public:
YY(int xx,int yy):XX(xx),y(yy){}
int getV(){return getX()+y;}
};
int main(){
YY c(3,4);
cout<<c.getV()+c.getX()<<endl;
return 0;
}
运行这个程序的输出结果是______。
单选题已知类MyClock中未显式定义构造函数,并重载了加法运算符,使得下面的语句序列能够正确执行:
MyClock c1,c2;
//......
c2=c1+10;
由此可知,为类MyClock重载的“+”运算符函数的声明是______。
单选题下列语句不能够用于打开C根目录下文件test.txt的语句是
A. ifstream fin;fin.open("C://test.txt");
B.ifstream fin("C://test.txt");
C.A)和B)
D. ifstream fin;fin("C://test.txt");
单选题下面关于运算符重载的描述错误的是( )。
A,运算符重载不能改变操作数的个数、运算符的优先级、运算符的结合性和运算符的语法结构
B.不是所有的运算符都可以进行重载
C.运算符函数的调用必须使用关键字operator
D.在C++语言中不可通过运算符重载创造出新的运算符
单选题一个函数为void f(int,char='a'),另一个函数为void f(int),则它们( )。
单选题有如下程序: #include<iostream> using namespace std; class A{ public: static int a; void init( ){a=l;} A(int a=2){init( );a++;} }; int A::a=0; A obj; int main( ){ cout<<obj.a; return 0; } 程序的输出结果是
单选题下列程序的输出结果为______。
#include<iostream. h>
void main()
{
char*a[]={"hello", "the", "world"};
char**pa=a;
pa++;
cout<<*pa<<endl;
}
单选题有如下程序: #include<iostream) using namespace std; classBase public: Base(int x=0)cout<<x; ; Class Derived:public Base public: Derived(int x=0)cout<<x; private: Base Val; ; int main() Derived d(1); return 0; A) 100 B) 000 C) 010 D) 001
单选题有如下程序:
#inClude
using namespaCe std;
Class test{
private:
int a;
publiC:
test( ){Cout<<”ConstruCtor”<
单选题下列程序的输出结果是( )。 #include<iostream.h> void main() char *str="12123434"; int x1=0,x2=0,x3=0,x4=0,i; for(i=0;str[i]!='/0';i++) switch(str[i]) case'1':x4++; case'2':x3++; case'3':x2++; case'4':x1++; cout<<x1<<","<<x2<<","<<x3<<","<<x4;
单选题下列选项中,不属于数据库管理的是( )。
单选题在C++中,cin是一个______。
