本文介绍了关于C ++中的继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个类名"CExchangeRate".尝试创建从CList< cexchangerate,cexchangerate&>继承的类名"CExchangeRates"时出现错误.
错误说明是:错误C2512:''CExchangeRate'':没有合适的默认构造函数,谁可以帮助我?

CExchangeRate的代码:

I create a class name "CExchangeRate". I got an error when I attempt to create a class name "CExchangeRates" which inherit from CList<cexchangerate,cexchangerate&>.
The error description is: error C2512:''CExchangeRate'': no appropriate default constructor available.Who can help me?

Codes of CExchangeRate:

#include <string>
#include <sstream>
using namespace std;


class CExchangeRate
{
public:
    CExchangeRate(string dividendCurrency,string divisorCurrency,double result);
    ~CExchangeRate(void);
    string displayInfo();
private:
    string _dividendCurr;
    string _divisorCurr;
    double _result;
};



CExchangeRates的代码:



Codes of CExchangeRates:

#include <Afxtempl.h>
#include "ExchangeRate.h"
class CExchangeRates : public CList<CExchangeRate,CExchangeRate&>
{
public:
    CExchangeRates(void);
    ~CExchangeRates(void);
};

推荐答案


这篇关于关于C ++中的继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 17:18