class foo; in header file

后端 未结 9 2161
执笔经年
执笔经年 2021-01-20 08:36

Is some one able to explain why header files have something like this?

class foo; // This here?
class bar
{
   bar();

};

Do you need an in

9条回答
  •  忘掉有多难
    2021-01-20 09:10

    That's a forward declaration. You need it for example if class bar has a pointer to a foo object, but you don't want to include the whole definition of the foo object immediately.

提交回复
热议问题