第20898题 单选题
给定C++代码中s1->draw()与s2->draw()输出不同结果的主要原因是什么?
class Shape {
public:
    virtual void draw() {
        cout << "绘制图形" << endl;
    }
    virtual ~Shape() {}
};
class Circle : public Shape {
public:
    void draw() override {
        cout << "绘制圆形" << endl;
    }
};
class Rectangle : public Shape {
public:
    void draw() override {
        cout << "绘制矩形" << endl;
    }
};
int main() {
    Shape* s1 = new Circle();
    Shape* s2 = new Rectangle();
    s1->draw();
    s2->draw();
    delete s1;
    delete s2;
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析