全部知识点
第6001题
下列关于this指针的叙述中,正确的是()。
第6002题
关于this指针的说法不正确的是()。
第6003题
有如下程序,若程序的输出结果是:123,则程序中横线处的语句是()。
#include<iostream>
using namespace std;
int i=1;
class Fun
{
public:
static int i;
int value(){ return i-1;}
int value()const{return i+1;}
};
int Fun::i=2;
int main()
{
int i=3;
Fun fun1;
const Fun fun2;
________;
return 0;
}
第6004题
下列关于对象概念的描述中,不正确的是()。
第6005题
静态数据成员在()进行初始化。
第6006题
在C++中,实现封装性需借助于()。
第6007题
下列关于类和对象的叙述中,错误的是()。
第6008题
有以下程序,在横线应添加()。
#include<iostream>
using namespace std;
class TestClass
{
public:
TestClass (int n){number=n;}
________//拷贝构造函数
~TestClass (){}
private:
int number;
};
TestClass fun(TestClass p)
{
TestClass temp(p);
return temp;
}
int main()
{
TestClass obj1(10),obj2(0);
TestClass obj3(obj1);
obj2=fun(obj3);
return 0;
}
第6009题
下述静态数据成员的特征中,错误的是()。
第6010题
类的析构函数的作用是()。
第6011题
类MyClass的定义如下:
class MyClass
{
public:
MyClass(){value=0;}
SetVariable(int i){value=i;}
private:
int value;
};则对下列语句序列正确的描述是()。
第6012题
有如下程序,运行时输出的结果是()。
#include<iostream>
using namespace std;
class A{
public:
static int a;
void init(){a=1;}
A(int a=2){init(); a++;}
};
int A::a=0;
A obj;
int main(){
cout<<obj.a;
return 0;
}
第6013题
()提供了类对外部的接口,私有成员是类的内部实现,而保护成员不允许外界访问,但允许派生类的成员访问,这样既有一定的隐藏能力,又提供了开放的接口。
第6014题
在下面的定义中,错误的语句是()。
class Sample
{
public:
Sample(int val); //①
~Sample(); //②
private:
int a=2.5; //③
Sample(); //④
};
第6015题
假定MyClass为一个类,则该类的拷贝初始化构造函数的声明语句为()。
第6016题
下面对静态数据成员的描述中,正确的是()。
第6017题
有如下类的定义,横线处的语句是()。
class MyClass
{
public:
MyClass(int a=0,int b=0)
{
X=a;
Y=b;
}
void Change() const
{
X=10;
Y=10;
}
private:
______ int X,Y;
};
第6018题
关于new运算符的下列描述中,错误的是()。
第6019题
下列关于this指针的叙述中,正确的是()。
第6020题
有如下程序,执行上面程序的过程中,构造函数 TestClass() 和 TestClass (const TestClass&x) 被调用的次数分别是()。
#include<iostream.h>
using namespace std;
class TestClass
{
public:
TestClass (){cout<<"default constructor\n";}
TestClass (const TestClass &x){cout<<"copy constructor\n";}
};
TestClass userCode(TestClass b){ TestClass c(b);return c;}
int main()
{
TestClass a,d;
cout<<"calling userCode\n";
d=userCode(a);
return 0;
}