Forward Declaration of Class, Function

前端 未结 6 1124
夕颜
夕颜 2021-01-04 19:26

When forward declarations of functions work in a source file (.cpp), why would the same doesn\'t work for classes ?

Thanks.

// main.cpp

void forwar         


        
6条回答
  •  庸人自扰
    2021-01-04 19:53

    The forward declaration class One; allows you to refer to the class itself but not to any of its members. You have to put all definitions of class members after the full declaration of the class. (Or inside, of course.)

提交回复
热议问题