我之前问过这个问题,但我使用了我被告知的内容来尝试让我的程序正常工作:
可能是因为我是 C++ 的菜鸟,但#ifndef
由于我的类包含相同的 .h 文件的问题,我无法使用。sh 和 th 和 main.cpp 都需要 rh 中定义的结构
我有
#include "s.h"
#include "t.h"
#ifndef r
#include "r.h"
#endlif
在我的主 cpp 文件中
在我的每个 sh 和 th 文件中,都有一个
#ifndef r
#include "r.h"
#endlif
// and then its class
同样,但是编译器在 rh 文件中给了我关于expected nested-name-specifier before "namespace"
, unqualified id before using namespace std;
,的错误,expected ';' before "namespace"
即使我在 rh 文件中的所有内容是:
#include <iostream>
using namespace std;
struct r{
// code
};
主要cpp没有导入某些库或其他东西引起的问题吗?我如何解决它?