我有这样的课...
class Container {
public:
class Iterator {
...
};
...
};
在其他地方,我想通过引用传递Container :: Iterator,但是我不想包含头文件。如果尝试转发声明该类,则会出现编译错误。
class Container::Iterator;
class Foo {
void Read(Container::Iterator& it);
};
编译上面的代码给出...
test.h:3: error: ‘Iterator’ in class ‘Container’ does not name a type
test.h:5: error: variable or field ‘Foo’ declared void
test.h:5: error: incomplete type ‘Container’ used in nested name specifier
test.h:5: error: ‘it’ was not declared in this scope
我该如何转发声明该类,这样就不必包括声明Iterator类的头文件了?
慕勒3428872
慕雪6442864
慕标5832272
相关分类