第21033题 单选题
C++类继承代码中Dog构造函数初始列表横线处填Animal(name)后程序的执行结果是?
class Animal {
public:
    std::string name;
    Animal(std::string str) : name(str) {
        std::cout << "Animal created\n";
    }
    virtual void speak() {
        cout << "Animal speaks" << endl;
    }
};

class Dog : public Animal {
    std::string breed;
public:
    Dog(std::string name, std::string b) : ____________, breed(b) {
        std::cout << "Dog created\n";
    }
    void speak() override {
        std::cout << "Dog barks" << endl;
    }
};

int main() {
    Animal* p = new Dog("Rex", "Labrador");
    p->speak();
    delete p;
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析