【发布时间】:2011-05-07 15:35:59
【问题描述】:
我之前问过这个问题,但我使用了我被告知的内容来尝试让我的程序运行:
这可能是因为我是 C++ 的菜鸟,但由于我的类包含相同的 .h 文件的问题,我无法使用 #ifndef。 s.h 和 t.h 和 main.cpp 都需要 r.h 中定义的结构
我有
#include "s.h"
#include "t.h"
#ifndef r
#include "r.h"
#endlif
在我的主 cpp 文件中
在我的每个 s.h 和 t.h 文件中,都有一个
#ifndef r
#include "r.h"
#endlif
// and then its class
同样,但编译器在 r.h 文件中给了我关于 expected nested-name-specifier before "namespace"、unqualified id before using namespace std;、expected ';' before "namespace" 的错误,即使我在 r.h 文件中只有:
#include <iostream>
using namespace std;
struct r{
// code
};
是主 cpp 没有导入某些库或其他东西引起的问题吗?我该如何解决?
【问题讨论】:
-
什么是'#endlif'?你的意思是'#endif'
标签: c++ header include include-guards