よくある質問ですが、コードが機能する方法を見つけることができないので、いくつかの助けを得ることができてうれしく思います。コード: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