class foo; in header file

后端 未结 9 2124
执笔经年
执笔经年 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:05

    Just curious, why do we need the term forward declaration at all? Isn't a forward declaration simply a declaration (as opposed to a definition)?

    class X;  // declaration
    
    class X   // definition
    {
        int member;
        void function();
    };
    

提交回复
热议问题