Suppose there is a source file un2.cpp
----un2.cpp----
class employee;
void employee::setname(string s)
{
.....(some code)
}
The employee class is defined in un2.h wherein setname() is declared. Now when i attempt to compile un2.cpp by 'cc -c un2.cpp -o un2.o', i get an error message
un2.cpp:3:16: error: invalid use of incomplete type ‘struct employee’
un2.cpp:1:7: error: forward declaration of ‘struct employee’
Why doesn't the compiler just take employee as an external symbol(like it would take a previously declared but undefined symbol) and compile the un2.cpp file.
Is there any difference between compiling a normal undefined symbol and a undefined class? Also can anyone tell me(if it is possible), the way to just forward declare a class and define the symbols in it?