Mọi người ơi, mình bị lỗi
main.cpp:46:9: error: no matching function for call to ‘Dog::Dog()’
Dog dogy;
Với đoạn code dưới đây. Không hiểu là bị sai gì?
Mọi người giúp mình nhé
#include<iostream>
using namespace std;
class Pet
{
protected:
string name;
public:
Pet(string n)
{
name = n;
}
virtual string getSound(){return "";};
void makeSound(void) { cout << name << "says: " << getSound() << endl; }
};
class Dog : public Pet
{
public:
Dog(string n): Pet(n){}
string getSound( )
{
return"gaugau";
}
};
int main()
{
Pet *point;
Dog dogy;
point=&dogy;
point->makeSound();
return 0;
}
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?