简体   繁体   English

我收到错误消息:Missing; *之前,但我没有错过

[英]I'm getting error: Missing ; before *, but I'm not missing it

I have commented everything out and the code now looks like this. 我已经注释掉了所有内容,现在代码看起来像这样。

//AOBSClass.h

#ifndef __AOBSCLASSHDR__
#define __AOBSCLASSHDR__

#include "IDriver.h"
#include "ActuationClass.h"

namespace AOBS
{
    class AOBSClass
    {
    public:
        AOBSClass(IDriver *driver);
        ~AOBSClass();

        IDriver *drivers;

        ActuationClass act;     

    private:

    };
}

#endif



// ActuationClass.h

#ifndef __ACTUATIONCLASSHDR__
#define __ACTUATIONCLASSHDR__

#include "AOBSClass.h"

namespace AOBS
{
    class ActuationClass
    {
    public:

        ActuationClass();
        ~ActuationClass();

        AOBSClass *aobs; // This line here

    private:

    };
}
#endif

I keep getting the errors below on the line shown above. 在上面显示的行中,我不断收到以下错误。 I have no idea what could be causing it. 我不知道是什么原因造成的。

error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

I'm using Visual Studio Express 2013. 我正在使用Visual Studio Express 2013。

The two files include each other! 这两个文件相互包含! Just put 刚放

class AOBSClass;

in the beginning of ActuationClass.h. 在ActuationClass.h的开头。

You have a circular dependency. 您具有循环依赖关系。 ActuationClass.h includes AOBClass.h and vice versa. ActuationClass.h包含AOBClass.h ,反之亦然。

To resolve this, remove the #include "AOBClass.h" in ActuationClass.h and just forward declare the AOBSClass . 要解决此问题,请在ActuationClass.h删除#include "AOBClass.h" ,然后向前声明AOBSClass

namespace AOBS
{
    class AOBSClass;      // Forward declare
    class ActuationClass
    {
    public:

        ActuationClass();
        ~ActuationClass();

        AOBSClass *aobs;

    private:

    };
}

You have circular includes. 您有通函包括。 Both header files include each other. 两个头文件都包括在内。 Generally, includes should go one way, like a tree structure. 通常,包含应采用一种方式,如树形结构。

A includes B includes C, etc A包括B包括C等

Also, as noted by others: a forward declaration can help with this sort of thing 另外,正如其他人所指出的:前向声明可以帮助解决此类问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Visual Studio 2013中,编译时出现有关缺少函数标头的错误 - In Visual Studio 2013, I'm getting an error about missing function header when compiling 缺少默认构造函数 - 但我没有调用它? - Default constructor missing - but I'm not calling it? 我在变量上得到3个C4703错误我认为我已经正确初始化了,我不确定我错过了什么 - I'm getting 3 C4703 errors on variables I think I've initialized correctly and I'm not sure what I'm missing 为什么我收到语法错误:缺少';' 前 '*' - Why am I getting Syntax error: missing ';' before '*' 链接错误。 我不知道我错过了什么 - Linking error. I don't know what I'm missing 为什么我会“丢失”; 在“ *”之前? - Why am I getting “missing ';' before '*' ”? 系统(“暂停”)无法正常工作,有人可以看到我所缺少的内容吗? - system(“pause”) not working, can anyone see what I'm missing? 使用空标签结构,编译器声称我缺少初始化程序,但我不是 - Use of empty tag struct, compiler claims I'm missing initializer, except I'm not Protobuf声明我显然没有丢失必填字段 - Protobuf declaring i'm missing required fields when i'm clearly not 我在这里遇到链接错误,为什么? - I'm getting a linking error here, why is that?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM