Class name does not name a type in C++

前端 未结 10 1970
情深已故
情深已故 2020-12-08 09:37

I just started programming in C++, and I\'ve tried to create 2 classes where one will contain the other.

File A.h:

#ifndef _A_h
#define          


        
10条回答
  •  爱一瞬间的悲伤
    2020-12-08 10:23

    The solution to my problem today was slightly different that the other answers here.

    In my case, the problem was caused by a missing close bracket (}) at the end of one of the header files in the include chain.

    Essentially, what was happening was that A was including B. Because B was missing a } somewhere in the file, the definitions in B were not correctly found in A.

    At first I thought I have circular dependency and added the forward declaration B. But then it started complaining about the fact that something in B was an incomplete type. That's how I thought of double checking the files for syntax errors.

提交回复
热议问题