17

这是我的 C++ 代码

// XuatChuoiBTHang.h
#pragma once
#include "BieuThuc.h"
#include "BieuThucHang.h"

class XuatChuoiBTHang
{
    public:
        virtual string xuatChuoi(BieuThucHang* btHang) = 0;     
};

// BieuThucHang.h
#pragma once
#include "bieuthuc.h"
#include "XuatChuoiBTHang.h"

class BieuThucHang : public BieuThuc
{
    private:
        XuatChuoiBTHang* xuatChuoiBTHang;
};

输出是:

“错误 C2061:语法错误:标识符‘BieuThucHang’”

如何解决?

4

1 回答 1

39

您有头文件的循环依赖。您需要通过在中使用前向声明来打破这种循环包含依赖XuatChuoiBTHang.h

class BieuThucHang;

此外,#include "BieuThucHang.h"XuatChuoiBTHang.h.

于 2013-03-30T06:56:02.133 回答