我试图在每个CClient类中创建一个CBuffer成员,如下所示:

#ifndef CCLI_INC
#define CCLI_INC
#include "CBuffer.h"
#include "main.h"

    class CClient
    {
    private:

        CBuffer *m_buffer;


    public:
        CClient();



    };


但是这段代码给了我

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


尽管我包含了cbuffer.h标头,但它给出了这个奇怪的错误。

最佳答案

转发声明CBuffer并丢失include

#ifndef CCLI_INC
#define CCLI_INC
#include "main.h"
class CBuffer;
class CClient
{
private:

    CBuffer *m_buffer;
public:
    CClient();
};

09-06 20:01