Originally Posted by
phantomotap
you must not declare any methods (member functions) where the parameters use the incomplete type unless it is with reference or pointer.
That's actually not quite the truth.
Code:
#include <iostream>
struct Test; // forward declare Test
Test func( Test t ); // <-- notice how both the return value type and the parameter are "by value"
struct Test
{
int a;
double b;
};
Test func( Test t )
{
Test copy = {};
copy.a = t.a * 3;
copy.b = t.b - 7.0;
return copy;
}
int main()
{
const Test a = { 16, 51.5 };
const Test b = func( a );
std::cout << "b.a = " << b.a << ", b.b = " << b.b << std::endl;
}