单选题

下列程序编译时有语法错误的语句是() #include
发布于 2022-03-03 17:36:40

下列程序编译时有语法错误的语句是()
#include<iostream>
#include<string>

using namespace std 

class Pet {
     string name
public:
     Pet(string p=" ") { name = p }
     string getName() const { return name }
     virtual void call() const=0
}

class Dog : public Pet{
public:
    Dog(string n) : Pet(n) {}
    void call() const { cout<< "##" << " " }
}

class Cat : public Pet{
public:
    Cat(string n) : Pet(n) {}
    void call() const { cout << "**" }
}

void f(Pet *p) {
    p->call()
}
int main() { 
    Pet pet0("#")    //(1)
    Dog pet1("*")    //(2)
    Cat pet2("$")    //(3)
    f(&pet1)         //(4)
    f(&pet2)         //(5)
    return 0
}

登录后免费查看答案

关注者
0
被浏览
38
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看