//header file
class Foo
{
public:
struct FooBar {
bool ok;
string msg;
};
};
// .cpp file
Foo::FooBar::FooBar():ok(false), msg("hello")
{}
Run Code Online (Sandbox Code Playgroud)
在尝试编译时,我得到:
错误:隐式声明'Foo :: FooBar :: FooBar()'的定义
愚蠢,简单的范围相关的错误我敢肯定,但我似乎无法发现它是什么...
您正在尝试实现未声明的构造函数.声明如下:
//header file
class Foo
{
public:
struct FooBar {
FooBar();
bool ok;
string msg;
};
};
// .cpp file
Foo::FooBar::FooBar():ok(false), msg("hello")
{}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
884 次 |
| 最近记录: |