I have gone thru the FAQ and have gone thru search but I am still confused. My header file has only the class and is using the macro guards and my cpp file has the actual functions with an include. I quickly wrote up a litte test prog, thinking my actual program may have other issues.
Code:#include "tst.h" int main() { tst x; x.run(); return (0); }Code:#include "tst.h" void tst::run() { cout<<"working"; }If I try to run this exact program I get the following errorsCode:#ifndef TST #define TST class tst { private: char ch; public: void run(); }; #endif
Compiling RUN.CPP:
Linking run.exe:
Linker Warning: No module definition file specified: using defaults
Linker Error: Undefined symbol tst::run() in module RUN.CPP
But if I change the include in main to #include "tst.cpp" the program runs. Why is this![]()



LinkBack URL
About LinkBacks



