Forward Declaration of Class, Function

前端 未结 6 1034
夕颜
夕颜 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:41

    when you create 2 class & one function can access data from on class to another class then it is a friend function

    forword declaration is use to know which class in next

    class abc;

    class xyz

    {

    data member;

    public:

    friend void getdata();

    other member function

    }

    class abc

    {

    data member

    public:

    friend void getdata();

    }

提交回复
热议问题