第三章单元测试
- 【析构函数】class Point
{
int x,y;
public: Point(){x=1;y=1;}
~Point(){cout << x<<'
,'<<y <<"is deleted."<< endl; }
};
void main()
{Point a;}
程序的运行结果为:Point 1,1 is deleted. ( ) - 【析构函数】构造函数和析构函数的执行顺序为先构造的后析构,后构造的先析构。( )
- 【成员函数】不属于成员函数的是( )。
- 【成员函数】设有以下类的定义:class Ex{ int x;public:void setx(int t=0);};若在类外定义成员函数setx(),以下定义形式中正确的是( )
- 【成员函数】有如下类定义:class sample {int n;public:sample (int i=0):n(i){ }void setValue(int n0);};下列关于setValue成员函数的实现中,正确的是( )。
A:错 B:对
答案:对
A:对 B:错
A:构造函数 B:静态成员函数 C:析构函数 D:友元函数
A:void Ex::setx(){ ... } B:void Ex::setx(int t) { ... } C:void setx(int t) { ... } D:Ex::void setx(int t) { ... }
A:setValue(int n0){n=n0;} B:void sample::setValue(int n0){n=n0;} C:sample::setValue(int n0){n=n0;} D:void setValue(int n0){n=n0;}
温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!