错误:尽管头包含,类尚未声明,代码在其他地方编译 [英] error: Class has not been declared despite header inclusion, and the code compiling fine elsewhere
问题描述
所以我有一个类包含在另一个类,不断抛出一个编译错误的形式错误:'ProblemClass'没有被声明。文件设置如此:
So I have a class included in another class that keeps throwing a compile error of the form "error: 'ProblemClass' has not been declared. The files are set up thusly:
#ifndef PROBLEMCLASS_H
#define PROBLEMCLASS_H
#include <iostream>
#include <cmath>
class ProblemClass
{
public:
virtual void Init() = 0;
};
#endif
,发生错误的类似如下:
and the class where the error occurs looks like this:
#ifndef ACLASS_H
#define ACLASS_H
#include "problemclass.h"
class AClass : public Base
{
public:
void DoSomething(ProblemClass* problem);
};
#endif
编译错误发生在void Dosomething();
The compile error occurs at void Dosomething();
我知道这里的代码不足以解决问题,我已经无法创建一个最小的例子,可以重现它所以我的问题是更一般的;什么样的事情可能会导致这种情况?有没有什么特别的,我应该寻找,或者一些调查线我应该跟踪跟踪它?
I'm aware the code here isn't enough to solve the problem. I've been unable to create a minimal example that can reproduce it. So my question is much more general; what sort of things might cause this? Is there anything in particular I should look for, or some line of enquiry I should be following to track it down?
这个代码编译在几乎相同版本的项目。
This code compiles fine in an almost identical version of the project.
任何类型的帮助将非常感谢,无论多么模糊。我在win 7 64位使用带有mingw4.4.1的代码块10.05。
Help of any sort would be greatly appreciated, no matter how vague. I'm using codeblocks 10.05 with mingw4.4.1 in win 7 64 bit.
推荐答案
你似乎在说,显示实际上不会产生编译器错误,你有一个问题。所以我们只能猜测。这里有一些可能性:
You seem to be saying that the code you are showing doesn't actually produce the compiler error that you are having a problem with. So we can only guess. Here are some possibilities:
这篇关于错误:尽管头包含,类尚未声明,代码在其他地方编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!