题目编号
语言
全部语言
等级
全部等级
考查知识点
选择考查知识点 (0)
找到 1505 道单选题
EXY-SC-1460
第 286 题

假设循环队列数组长度为 $N = 7$ ,队空判断条件为 front == rear 。入队和出队操作如下:

const int N = 7;
int q[N];
int front = 3, rear = 3;

void enqueue(int x) {
    q[rear] = x;
    rear = (rear + 1) % N;
}

void dequeue() {
    front = (front + 1) % N;
}

依次执行:

enqueue(10);
enqueue(20);
enqueue(30);
dequeue();
enqueue(40);
dequeue();
enqueue(50);

最终 (front, rear) 的值是( )。

A

(5, 1)

B

(4, 0)

C

(5, 0)

D

(3, 1)

语言: C++
GESP真题 六级
2026.6
单选题号: 5
EXY-SC-1459
第 287 题

某文本编辑器把用户输入的字符依次压入栈 S 。用户依次输入 X, Y, Z, W 后,连续执行两次撤销操作。每次撤销都会弹出栈顶一个字符。此时栈从栈底到栈顶的内容是( )。

A

X Y

B

X Y Z

C

Y Z

D

X Z

语言: C++
GESP真题 六级
2026.6
单选题号: 4
EXY-SC-1458
第 288 题

下面代码在 main() 中有一行会导致编译错误,请找出来。

class Student {
public:
    Student(string n, int s) : name(n), score(s) {}

    string getName() {
        return name;
    }

    void setScore(int s) {
        score = s;
    }
private:
    string name;
    int score;
};

int main() {
    Student stu("Tom", 85);
    cout << stu.getName(); // ①
    stu.setScore(90);      // ②
    stu.score = 100;       // ③
    cout << stu.getName(); // ④
    return 0;
}
A

第 ① 行

B

第 ② 行

C

第 ③ 行

D

第 ④ 行

语言: C++
GESP真题 六级
2026.6
单选题号: 3
EXY-SC-1457
第 289 题

下列代码中, d1->work(); 和 d2->work(); 输出不同结果的主要原因是( )。

class Device {
public:
    virtual void work() {
        cout << "Device is working" << endl;
    }
    virtual ~Device() {}
};

class Printer : public Device {
public:
    void work() override {
        cout << "Printer is printing" << endl;
    }
};

class Scanner : public Device {
public:
    void work() override {
        cout << "Scanner is scanning" << endl;
    }
};

int main() {
    Device* d1 = new Printer();
    Device* d2 = new Scanner();

    d1->work();
    d2->work();

    delete d1;
    delete d2;
    return 0;
}
A

Printer 和 Scanner 使用了相同的构造函数。

B

work() 是虚函数,且 d1 和 d2 实际指向不同派生类对象,发生动态绑定。

C

d1 和 d2 是不同的指针变量。

D

程序中使用了 delete 释放对象。

语言: C++
GESP真题 六级
2026.6
单选题号: 2
EXY-SC-1456
第 290 题

下列关于 C++ 中继承和多态的描述中,错误的是( )。

A

通过基类指针调用虚函数时,会根据对象实际类型决定调用版本。

B

基类析构函数常声明为虚函数,以便通过基类指针正确释放派生类对象。

C

派生类可以重写基类中的虚函数。

D

构造函数可以声明为 virtual ,以便在构造对象时实现动态绑定。

语言: C++
GESP真题 六级
2026.6
单选题号: 1
当前页显示 286 - 290 ,共 1505 道单选题