单选题有以下程序:
#include<iostream>
using namespace std;
Class sample
{
private:
int n;
public:
sample(){}
sample(int m)
{
n=m;
}
sample add(sample s1,samplc s2)
{
this-->n=s1.n+s2.n;
return(*this);
}
void disp()
{
cout<<“n=”<<n<<endl;
}
};
int main()
{
sample s1(10),s2(5),s3;
s3.add(s1,s2);
s3.disp();
return 0;
}
程序运行后,输出的结果是
____
。
单选题有如下程序:
#inClude using namespaCe std; Class B{
publiC:
virtual void show(){Coutshow();} void fUN2(B&ref){ref.show();}
voidfhIl3(B B.{b.show();} int main()
{
B b,* P=new D; D d;
funl(P); fun2(B.; fun3(D);
delete P; return 0; }
执行这个程序的输出结果是( )。
单选题下列叙述中正确的是( )。
单选题继承具有
____
,即当基类本身也是某一个类的派生类时,底层的派生类也会自动继承间接基类的成员。
单选题若已定义
inta[]={1,2,3,4,5,6,7,8,9,10},p=a,i=5;
则对数组元素不正确的引用是( )。
单选题对于语句cout<<endl<<x中的各个组成部分,下列叙述中错误的是( )。
单选题有如下类定义:
class MyClass
{
public:
______
private:
int data;
};
若要为MyClass类重载流输入运算符“>>”,使得程序中可以“cin>>obj;”的形式改变MyClass类的对象obj中数据成员data的值,则横线处的声明语句应为______。
单选题有如下类定义:
class AA{
int a;
public:
AA(int n=0):a(n){}
};
class BB:public AA{
public:
BB(int n)______
};
其中横线处缺失部分是______。
单选题有以下程序 #include<iostream> using namespace std; int a; int fun(); int main() extern int a; int b; a=100; b=fun(); cout<<b<<endl; return 0; int fun() extern int a; return(10*a); 其程序运行后的输出结果是( )。
单选题对C++编译器区分重载函数无任何意义的信息是______。
单选题若有定义“int a[2][3];”,下列选项中对a数组元素正确引用的是______。
单选题有下列的程序: #include<cstring.h> #include<iostream.h> using namespace std; class MyString { public: MyString(const char*s); ~MyString(){delete[]data;} protected: unsigned len; char*data; }; MyString::MyString(const char*s) { len=strlen(s); data=new char[len+1); strcpy(data,s); } int main() { MyString a("C++Programing"); MyString b(a); return 0; } 在运行上面的程序时出错,出错的原因是( )。
单选题下列字符串中不能作为C++标识符使用的是( )。
单选题有如下程序
#include<iostream>
using namespace std;
class Base{
protected:
Base(){cout<<"A";}
Base(char C){cout<<c;}
};
class Derived:public Base{
public:
Derived(char C){cout<<c;}
};
int main(){
Derived d1("B");
return 0;
}
执行这个程序屏幕上将显示输出______。
单选题有以下程序void f(int x,int y) int t, if(x<y)t=x;x=y;t;main() int a=4,b=3,c=5; f(a,B) ;f(a,C) ;f(b,C) ; cout<<a<<","<<b<<","<<c<<end1;执行后输出结果是
单选题下面程式程序的执行结果是( )。 #include <iostream.h> void main() int*p,r; p=new int; *p=20; r=sizeof(*p); cout<<r<<endl; delete p; A.程序错误 B.内存为20地址的大小 C.20 D.4
单选题软件需求分析阶段建立原型的主要目地是 ______。
单选题下列情况中,不会调用拷贝构造函数的是( )。
单选题有如下程序 #include<iostream> using namespace std; class Base{ protected: Base(){cout<<'A';} Base(char c){cout<<c;} }; class Derived:public Base{ public: Derived(char c){cout<<c;} }; int main(){ Derived dl('B'); return 0; } 执行这个程序屏幕上将显示输出( )。
单选题在C++中,实现封装性需借助于( )。 A.枚举 B.类 C.数组 D.函数
