我知道這是經常被問到的問題,但我想不出我的代碼工作的方式,所以我會很高興得到一些help.Here的代碼:C++錯誤:沒有適當的默認構造函數可用
#include "stdafx.h"
#include "iostream"
#include "string"
#include "cmath"
#include "ctime"
using namespace std;
class quad{
int Lice;
public:
quad(int x, int z){
Lice = x*z;
}
int ShowLice(){
return Lice;
}
};
class tri : public quad{
int Lice;
public:
tri(int a, int b, int c){
Lice = a*b*c;
}
};
int main(){
quad ob1(2,2);
tri ob2(2,2,2);
cout<<ob1.ShowLice();
cout<<ob2.ShowLice();
return 0;
}
我使用VS2008和編譯器錯誤是:
project1.cpp(20) : error C2512: 'quad' : no appropriate default constructor available
謝謝,Leron。
謝謝,現在工作得很好。 – Leron