Friend methods in C++ is not working

后端 未结 2 1568
借酒劲吻你
借酒劲吻你 2021-01-28 12:17

I wrote the following code:

class Osoba{
private:
    string imie, nazwisko, kolorOczu;
    friend void Dziecko::coutall();
public:
    Osoba(string imie, string         


        
2条回答
  •  抹茶落季
    2021-01-28 12:35

    You cannot do it, because Dziecko::coutall is not defined when Osoba is compiled and there are no means in c++ to make forward member method declaration. Instead you can make friend all Dziecko class (as Nbr44 suggested)

提交回复
热议问题