单选题

一个类可以有多个构造函数,这种特性称为构造函数重载。( )

A、

正确 

B、 错误
下载APP答题
由4l***sy提供 分享 举报 纠错

相关试题

单选题 有关下面C++代码的说法,错误的是( )。

 1  #include <iostream>

 2  using namespace std;

 3

 4  class MoreData {

 5      int * _data;

 6      int head, tail, capacity;

 7  public:

 8      MoreData(int cap) {

 9          capacity = cap;

10          _data = new int[capacity];

11          head = tail = 0;

12      }

13      MoreData & push(int val) {

14          _data[tail++] = val;

15          return *this;

16      }

17      int pop(){

18          return _data[head++];

19      }

20      int size() {

21          return tail - head;

22      }

23  };

24  int main() {

25      auto myData = MoreData(100);

26      myData.push(1);

27      myData.push(2);

28      myData.push(3);

29      myData.push(11).push(12).push(13);

30      cout << myData.pop() << endl;

31      return 0 ;

32  }


A、

MoreData类可用于构造队列(Queue)数据结构。

B、

代码第29行,连续push()的用法将导致编译错误。

C、

_data是MoreData类的私有成员,只能在类内访问。

D、

以上说法均没有错误。

单选题 在C++中,类的静态成员变量只能被该类对象的成员函数访问。

A、

B、

单选题 在C++中,break语句只能用于循环语句和switch语句中。()

A、

正确 

B、

错误

单选题 关于C++类和对象的说法,错误的是()。

A、

C++中,一切皆对象,即便是字面量如整数5等也是对象

B、

在C++中,可以自定义新的类,并实例化为新的对象

C、

在C++中,内置函数和自定义函数,都是类或者对象

D、

在C++中,可以在自定义函数中嵌套定义新的函数

单选题 数组在内存中是连续存储的,所以其随机访问效率很高。()

A、

正确

B、错误

单选题 若有一个哈夫曼树,其叶子节点个数为n,则该哈夫曼树的节点总数为()

A、

2n -1

B、

2n

C、2n+1
D、n+1

单选题 运⾏以下C++代码,屏幕将输出“derived class”。


#include <iostream>

using namespace std;

 

class base {

public:

    virtual void show() {

        cout << "base class" << endl;

    }

};

 

class derived : public base {

public:

    void show() override {

        cout << "derived class" << endl;

    }

};

 

int main() {

    base* b;

    derived d;

    b = &d;

    b->show();

    return 0;

}

A、

B、

单选题 有关下面C++代码的说法,错误的是( )

 1  #include <iostream>

 2  using namespace std;

 3

 4  class MoreData {

 5      int * _data;

 6      int head, tail, capacity;

 7  public:

 8      MoreData(int cap) {

 9          capacity = cap;

10          _data = new int[capacity];

11          head = tail = 0;

12      }

13      MoreData & push(int val) {

14          _data[tail++] = val;

15          return *this;

16      }

17      int pop(){

18          return _data[head++];

19      }

20      int size() {

21          return tail - head;

22      }

23  };

24  int main() {

25      auto myData = MoreData(100);

26      myData.push(1);

27      myData.push(2);

28      myData.push(3);

29      myData.push(11).push(12).push(13);

30      cout << myData.pop() << endl;

31      return 0 ;

32  }

A、

MoreData 类可用于构造队列(Queue)数据结构。

B、

代码第29行,连续 push() 的用法将导致编译错误。

C、

__data 是 MoreData 类的私有成员,只能在类内访问。

D、

以上说法均没有错误。