When designing a class, how to use the class defined later?


class class1
{
public:
    friend void Print(class1 &a, class2 &b);
};

class class2
{
public:
    friend void Print(class1 &a, class2 &b);
};

this is the problem. I have a function that has objects of two classes in its parameters, and I want to access private members of both objects at the same time, so I declare the function as a friend function of these two classes, but the compiler prompts me:
syntax error: identifier "class2"
I find that it is because class2 is defined later, so the front class2 is not visible. What should I do now? How do you usually deal with this problem in programming?

CPP
Mar.11,2021

just declare it all at the front.

class class1;
class class2;

class class1
{
public:
    friend void Print(class1 &a, class2 &b);
};

class class2
{
public:
    friend void Print(class1 &a, class2 &b);
};
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-49dce31-1df1c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-49dce31-1df1c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?