嵌套结构的前向声明

时间:2016-11-07 13:06:39

标签: c++ inner-classes forward-declaration

考虑这种情况:

struct Foo
{
    struct Bar
    {
    };
};

如何转发声明Foo::Bar

我尝试了什么:

struct Foo::Bar;
  

错误:'Foo'尚未声明

struct Foo;
struct Foo::Bar;
  

错误:'struct Foo'中的'Bar'没有命名类型

namespace Foo
{
    struct Bar;
}
// ...
struct Foo
{
    struct Bar
    {
    };
};
  

错误:'struct Foo'重新声明为不同类型的符号

struct Foo
{
    struct Bar;
};
// ...
struct Foo
{
    struct Bar
    {
    };
};
  

错误:重新定义'struct Foo'

0 个答案:

没有答案
相关问题