您的位置:首页 > 编程语言 > C语言/C++

运维调试记录:C++ compile error: default argument given for parameter

2016-04-05 12:37 721 查看

问题:

编译C++代码时出现错误提示如下:

> g++ *.cpp

fileTest.cpp:17:117: error: default argument given for parameter 1 of ‘MyClass::fileTest(const string&, std::string, std::string, std::string)’ [-fpermissive]

fileTest.h:15:14: error: after previous specification in ‘MyClass::fileTest(const string&, std::string, std::string, std::string)’ [-fpermissive]


解决办法:

既可以在类的声明中,也可以在函数定义中声明缺省参数,但不能既在类声明中又在函数定义中同时声明缺省参数。

You can declare default arguments in the class declaration or in the function definition, but not both.

因此,将定义或声明中的任一个缺省参数删除即可。

参考网址

http://stackoverflow.com/questions/13295530/this-is-a-new-compile-error-for-me
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C++