i am writing a program to reorder events in the correct based on a date that the user provides, i am getting an error in buildtime.
Main.cpp||In function 'int main()':|
Main.cpp|9|error: aggregate 'Stuff event1' has incomplete type and cannot be defined|
Main.cpp|10|error: aggregate 'Stuff event2' has incomplete type and cannot be defined|
Main.cpp|9|warning: unused variable 'event1' [-Wunused-variable]|
Main.cpp|10|warning: unused variable 'event2' [-Wunused-variable]|
||=== Build finished: 2 errors, 2 warnings ===|
Forward declaration of a class allows you to refer to the class type, but not actually use it (or any of its members). You could have a pointer to one.
All the compiler can leave until later is function calls, which get filled in by the linker as necessary. It needs to know everything else about an object when it has to use it, and compilers read the code once only from top to bottom (or, if they do multi-pass, they still act as if they only read it once).