この質問は以前に尋ねられていますが、私は解決策を投稿しようとしましたが、何らかの理由で私が直面している問題を解決できません。引数リストに一致するコンストラクタのインスタンスがありません
派生クラスのオブジェクトを作成しようとしています。
Error: no instance of constructor "CALibrary::YieldCurve::YieldCurve" matches te argument list argument types are: (std::string, std::vector<std::pair<double,double>,double>)
親クラスがある:
namespace CALibrary {
class YieldCurveIF {
public:
virtual double getDiscountFactor(double fromDate, double toDate) = 0;
int getSize() {
return _curve.size();
}
std::vector<std::pair<double, double>> getCurve() {
return _curve;
}
void setParameters(std::string curveName,
std::vector<std::pair<double, double>>& curve)
{
_curveName = curveName;
_curve = curve;
}
protected:
std::string _curveName;
std::vector<std::pair<double, double>> _curve;
};
}
派生クラスがある:ここでは
namespace CALibrary {
class YieldCurve : public CALibrary::YieldCurveIF
{
public:
YieldCurve(std::string curveName,
std::vector<std::pair<double, double>>& curve)
{
setParameters(curveName, curve);
}
double getDiscountFactor(double fromDate, double toDate);
private:
};
}
は私のコードであるしかし、私はというエラーメッセージが表示されますYieldCurveのオブジェクトを作成しようとすると:
int nPayments = 4;
std::string curveName = "EURCurve";
std::vector<std::pair<double, double>, double> yCurve(nPayments);
CALibrary::YieldCurve _yieldCurve(curveName, yCurve);
「CALibrary :: YieldCurve _yieldCurve(curveName、yCurve);」という行にエラーが発生しました。特に変数 "curveName"です。 – Ace
'yCurve'(最後のコードの3行目)の型を修正しようとしましたか?第3の「ダブル」は存在してはならない。 – kennytm