#ifndef _HUOPAOINITIAL
#define _HUOPAOINITIAL
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
typedef struct _strInitialPara//系统参数初始化
{
double dIvestiRg;//侦查距离
double dFrequency;//传声器范围
}strInitialPara;
class CHuoPaoInitial//class declaration
{
public:
CHuoPaoInitial(bool bDamageSatus,bool bOnOffControl):
m_bDamageSatus(bDamageSatus),
m_bOnOffControl(bOnOffControl)
{
m_strInitialPara.dIvestiRg = 200000;
m_strInitialPara.dFrequency= 2000;
}//endof CHuoPaoInitial
~CHuoPaoInitial(){}
int huo_pao_initial() ;
int GetSysState() const;
strInitialPara GetIntialPara() const;
private:
strInitialPara m_strInitialPara;
bool m_bDamageSatus;//毁伤状态 1on 0off
bool m_bOnOffControl;//开关机控制 1on 0off
int m_a;//返回值模拟系统状态反馈
};
#endif
对应的.cpp如下:
#include "stdafx.h"
#include "HuoPaoInitial.h"
int CHuoPaoInitial::huo_pao_initial()
{
cout<<"距离:"<<setw(5)<<m_strInitialPara.dIvestiRg<<endl;
cout<<"频率:"<<setw(5)<<m_strInitialPara.dFrequency<<endl;
if ((1==m_bDamageSatus) && (1==m_bOnOffControl))
{
cout<<"正常"<<endl;
m_a = 1;
return m_a;
}
else
{
cout<<"毁伤"<<endl;
m_a = 0;
return m_a;
}
}
strInitialPara CHuoPaoInitial::GetIntialPara()
{
return m_strInitialPara;
}
int CHuoPaoInitial::GetSysState()
{
return m_a;
}
报错:
error C2511: 'GetIntialPara' : overloaded member function 'struct _strInitialPara (void)' not found in 'CHuoPaoInitial'
error C2511: 'GetSysState' : overloaded member function ''int (void)' not found in 'CHuoPaoInitial'
error C2512: 'CHuoPaoInitial' : no appropriate default constructor available
error C2512: 'CHuoPaoInitial' : no appropriate default constructor available
1 个解决方案
#1
没有缺省构造函数, 还有在CPP中把那些const的后缀加上
#1
没有缺省构造函数, 还有在CPP中把那些const的后缀加上