#include<iostream>
using namespace std;
class DongVat
{
protected:
double canNang;
public:
DongVat(double w);
void inDL();
};
class SuTu: public DongVat{
private:
double tocDo;
public:
SuTu(double w, double s);
void inDL();
};
class TranNuoc: public DongVat{
private:
double chieuDai;
public:
TranNuoc(double w, double t);
void inDL();
};
int main()
{
SuTu s1(200, 120);
cout << "Thong tin cua Su Tu:";
s1.inDL();
cout<<endl;
TranNuoc t1(250 , 3);
cout << "Thong tin cua Tran Nuoc: ";
t1.inDL();
cout <<endl;
system("pause");
return 0;
}
DongVat::DongVat(double w):canNang(w){
}
void DongVat::inDL(){
cout << "\nCan nang: "<<canNang;
}
SuTu::SuTu(double w, double s):tocDo(s){ //Dong 46.
DongVat::DongVat(w);
}
void SuTu::inDL(){
DongVat::inDL();
cout << "\nToc do: "<<tocDo;
}
TranNuoc::TranNuoc(double w, double t):chieuDai(t){ //Dong 53.
DongVat::DongVat(w);
}
void TranNuoc::inDL(){
DongVat::inDL();
cout << "\nChieu dai: "<<chieuDai;
}
nó báo lỗi : error C2512: ‘DongVat’ : no appropriate default constructor available. Ở dòng 46 và 53.
Vậy có nghĩa là sao vậy, mong mọi người giúp mình.
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?