Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error C2061: syntax error : identifier [closed]

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 ?

like image 325
DungLe Avatar asked Mar 30 '13 06:03

DungLe


1 Answers

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.

like image 61
Alok Save Avatar answered Nov 06 '22 02:11

Alok Save