C++为什么我会得到“不命名类型”错误?
我主要的I类有:C++为什么我会得到“不命名类型”错误?
#include "main.h"
outPut O;
int main(){
...
}
其中main.h文件#包括 “outPut.h”
的 “outPut.h” 线路有:
#ifndef OUTPUT_H
#define OUTPUT_H
#include <iostream>
#include <fstream>
#include "properties.h"
#include "particles.h"
class outPut{
public:
outPut();
std::ofstream file;
void show(lipid * l);
};
#endif
和outPut.cpp:
#include "outPut.h"
outPut::outPut(){
}
当我编译这个我得到的错误:
main.cpp:3: error: ‘outPut’ does not name a type
为什么这么说?
谢谢...
编辑,找到它。 main.h没有保存,并且#include“outPut.h”被取消。
您需要在main.cpp
的#include "outPut.h"
。
我仍然在学习C++。为什么在main.h中包含outPut.h不够好? – 2011-04-28 18:16:22
It is inc通过main.hluded。 – Yotam 2011-04-28 18:17:00
哦,我错过了。 Bleh,删除答案按钮在哪里... – alternative 2011-04-28 18:17:08
grep for OUTPUT_H在所有源文件中。您可能无意中在包含outPut.h之前的其他头文件中定义了include guard。
你如何编译这个? – 2011-04-28 18:14:26
@Mihran它不是一个链接错误,所以编译可能不需要的信息。 – alternative 2011-04-28 18:16:23
g ++后跟所有相关文件(在这种情况下,g ++ main.cpp outPut.cpp properties.cpp particles.cpp – Yotam 2011-04-28 18:16:28