【发布时间】:2013-12-08 02:17:47
【问题描述】:
我收到错误消息:
thing.cpp:5:1: error: ‘SquareThing’ does not name a type
SquareThing::SquareThing()
^
compilation terminated due to -Wfatal-errors.
make: *** [thing.o] Error 1
我的东西.h 文件:
#define THING_H_
#ifndef THING_H_
#include <vector>
#include <iostream>
class SquareThing{
public:
SquareThing();
//other functions
private:
int something;
//more members
};
#endif
任何我的东西.cpp:
#include "thing.h"
#include <vector>
#include <iostream>
using namespace std;
SquareThing::SquareThing()
{
something = 3;
}
//more functions below
这似乎太简陋了,但我似乎真的找不到错误。非常感谢任何帮助。
【问题讨论】:
-
通常,标头保护
MAZE_H_会反映文件的名称,以避免重复。如果您的任何其他文件也定义了MAZE_H_,则您的整个thing.h标头将被跳过... -
抱歉,我在放置“MAZE_H_”而不是“THING_H_”时犯了一个根本性错误。我的实际代码有 'THING_H_' 但仍然无法编译。
标签: c++ constructor compiler-errors header-files