C++问题(no matching function for call to)
头文件里是:enumLOGMODE{M_DEFAULT,M_DAY,M_SIZE};classStatuslogfile{public:Statuslogfile(cha...
头文件里是:
enum LOGMODE { M_DEFAULT, M_DAY, M_SIZE };
class Statuslogfile
{
public:
Statuslogfile( char *f, LOGMODE lm, int ms);
~Statuslogfile();
CPP文件里是:
Statuslogfile::Statuslogfile( char * f, LOGMODE lm=M_DEFAULT, int ms=0 )
{
fd = -1;
strcpy( fileName, f );
logMode=lm;
msize=ms;
getToday(CREATEDAY);
}
Statuslogfile::~Statuslogfile()
{
closefile();
}
报错:
StatusLogFile.h:24: note: candidates are: Statuslogfile::Statuslogfile(char*, LOGMODE, int)
StatusLogFile.h:22: note: Statuslogfile::Statuslogfile()
StatusLogFile.h:19: note: Statuslogfile::Statuslogfile(const Statuslogfile&)
大侠帮忙解决一下啊!
还有,test.cpp前几行是:
#include "StatusLogFile.h"
int main()
{
Statuslogfile *log = new Statuslogfile("log.dat");
报错:
test.cpp:4: error: no matching function for call to ‘Statuslogfile::Statuslogfile(const char [8])’ 展开
enum LOGMODE { M_DEFAULT, M_DAY, M_SIZE };
class Statuslogfile
{
public:
Statuslogfile( char *f, LOGMODE lm, int ms);
~Statuslogfile();
CPP文件里是:
Statuslogfile::Statuslogfile( char * f, LOGMODE lm=M_DEFAULT, int ms=0 )
{
fd = -1;
strcpy( fileName, f );
logMode=lm;
msize=ms;
getToday(CREATEDAY);
}
Statuslogfile::~Statuslogfile()
{
closefile();
}
报错:
StatusLogFile.h:24: note: candidates are: Statuslogfile::Statuslogfile(char*, LOGMODE, int)
StatusLogFile.h:22: note: Statuslogfile::Statuslogfile()
StatusLogFile.h:19: note: Statuslogfile::Statuslogfile(const Statuslogfile&)
大侠帮忙解决一下啊!
还有,test.cpp前几行是:
#include "StatusLogFile.h"
int main()
{
Statuslogfile *log = new Statuslogfile("log.dat");
报错:
test.cpp:4: error: no matching function for call to ‘Statuslogfile::Statuslogfile(const char [8])’ 展开
3个回答
展开全部
大概是要你用OVERLOAD吧...
简单一点...把另外两个para也打进去就好了
简单一点...把另外两个para也打进去就好了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Statuslogfile("log.dat")调用的是哪个构造函数?
Statuslogfile(char*, LOGMODE, int),
Statuslogfile(),
Statuslogfile(const Statuslogfile&)
跟哪个匹配呢?
Statuslogfile(char*, LOGMODE, int),
Statuslogfile(),
Statuslogfile(const Statuslogfile&)
跟哪个匹配呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询