Tho*_*mas 12 c++ forward-declaration
我有一个头文件,有一些前向声明但是当我在实现文件中包含头文件时,它包含在先前的前向声明的包含之后,这会导致像这样的错误.
error: using typedef-name ‘std::ifstream’ after ‘class’
/usr/include/c++/4.2.1/iosfwd:145: error: ‘std::ifstream’ has a previous declaration.
class ifstream;
class A
{
    ifstream *inStream;
}
// End of A.h
#include <ifstream>
using std::ifstream;
#include "A.h"
// etc
什么是解决这个问题的常态?
提前致谢.
chi*_*uit 23
不要转发声明std:ifstream  - 只需导入<iosfwd>.
ifstream是一个typedef.
有关详细信息,请参见此处:http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.2/group__s27__2__iosfwd.html
| 归档时间: | 
 | 
| 查看次数: | 5918 次 | 
| 最近记录: |