codeblocks - undefined reference to Class::Function() C++ -


after searching solution half hour have made no progress. errors follows:

s\my workspace\project\main.cpp - line 7 - undefined reference 'sally::sally()'

s\my workspace\project\main.cpp - line 9 - undefined reference 'sally::printcrap()'

main.cpp

#include <iostream> using namespace std; #include "sally.h"  int main() {     sally sallyobject;     sallyobject.printcrap(); } 

sally.h

#ifndef sally_h #define sally_h   class sally {     public:         sally();         void printcrap(); };  #endif // sally_h 

sally.cpp

#include "sally.h" #include <iostream> using namespace std;  sally::sally(){ }  void sally::printcrap(){     cout << "did steak?" << endl; } 

thank in advance!

i know pretty old question maybe someone.

so, when adding additional files (headers, source, etc.) follow this:

new file -> file... -> c/c++ header (source, etc.) -> next, next -> give name , make sure it's in same path project, check "add file active project", in build target(s): check -> finish.

hope helps.


Comments