Use function returning incomplete type as default argument
When I try to compile and run this code (only the first three lines really matter): class object; object getObject(); void doSomething(object o = getObject()); class object{ public: int num = 0; }; object getObject(){ return {}; } void doSomething(object o){ o.num = 5; } int main(){} I get this error: main.cpp:3:39: error: invalid use of incomplete type 'class object' void doSomething(object o = getObject()); ^ main.cpp:1:7: note: forward declaration of 'class object' class object; ^ How would I get it to compile without changing the order of everything? In my actual code, the declarations are