Hi...
I've been wondering this problem for a while today. I thought it can't be this weird because it's in so small scale...but...here it is. Maybe you understand why it gives me unresolved external?
normal_screen.h:
normal_screen.cpp:Code:#ifndef NORMAL_SCREEN_H #define NORMAL_SCREEN_H #include "clock_window.h" class Normal_screen : public Clock_window { public: Normal_screen(); ~Normal_screen(); Clock_window& gClockWin(); private: Clock_window clockWin; }; #include "normal_screen.cpp" #endif
So...should be very simple but still it gives me two errors:Code:#ifndef NORMAL_SCREEN_CPP #define NORMAL_SCREEN_CPP Normal_screen::Normal_screen() {} Normal_screen::~Normal_screen() {} Clock_window& Normal_screen::gClockWin() { return clockWin; } #endif
"[Linker Error] Unresolved external 'Normal_screen::~Normal_screen()' "
and
"[Linker Error] Unresolved external 'Normal_screen::Normal_screen()' ".
And yet it works if I define the constructor and destructor in file normal_screen.h like this:
So, how's that possible?? Something about linker/compiler options?Code:#ifndef NORMAL_SCREEN_H #define NORMAL_SCREEN_H #include "clock_window.h" class Normal_screen : public Clock_window { public: Normal_screen(); ~Normal_screen(); Clock_window& gClockWin(); private: Clock_window clockWin; }; Normal_screen::Normal_screen() {} Normal_screen::~Normal_screen() {} #include "normal_screen.cpp" #endif![]()



LinkBack URL
About LinkBacks




So, that's for the definitions of header file declarations. Like for that evil constructor and destructor and if there are something else declared in the file. Should it be done somehow else? 
Not the longest session, though.