C++ compiler option to allow the use of incomplete type in classes that make use of each other?

101 Views Asked by At

Is there a compiler option that will allow the following code to compile, without moving the function definition to the bottom?

class first{
    int a;

    void func(second b){}

};

class second{
    int a;

    void func(first b){}
};

1

There are 1 best solutions below

0
On

Nope, not when you pass it by value. If you passed it by pointer or by reference you could.