题目
原题目使用Java作为示范,本文章提供C++解法。
猫狗两个类的定义如下
public class Pet {
private String type;
public Pet(String type){
this.type = type;
}
public String getPetType(){
return this.type;
}
}
public class Dog extends Pet {
public Dog() {
super("dog");
}
}
public class Cat extends Pet {
public Cat(String type) {
super("cat");
}
}
实现一种猫狗队列的结构,要求如下: