Here is my C++ code
// 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;
};
Ouput is:
"error C2061: syntax error : identifier 'BieuThucHang' "
How to fix it ?
You have a circular dependency of header files. You need to break this circular inclusion dependency by
using a forward declaration in XuatChuoiBTHang.h
:
class BieuThucHang;
Also, remove #include "BieuThucHang.h"
from XuatChuoiBTHang.h
.