第38894题 单选题
下面的代码在 main() 中有一行会导致编译错误,请找出来。
class Pet {
public:
    Pet(string n, int a) : name(n), age(a) {}
    string getName() { return name; }
    void birthday() { age++; }
private:
    string name;
    int age;
};

int main() {
    Pet cat("奶茶", 2);
    cout << cat.getName(); // ①
    cat.birthday(); // ②
    cat.name = "大橘"; // ③
    cout << cat.getName(); // ④
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析