I am a novice programmer in c++, and I am currently getting a compiling error
Undefined symbols for architecture x86_64 Supposedly this originates from how the header files and implementation files are included/coded.
Below is some code that generates the compiling error I am receiving
Main
//Main.cpp #include <iostream> #include <string> #include "Animal.hpp" using namespace std; int main(){ Animal myPet; myPet.shout(); return 0; } Header
//Animal.hpp #ifndef H_Animal #define H_Animal using namespace std; #include <string> class Animal{ public: Animal(); void shout(); private: string roar; }; #endif Implementation
//Animal.cpp #include "Animal.hpp" #include <string> Animal::Animal(){ roar = "..."; } void Animal::shout(){ roar = "ROAR"; cout << roar; } This code generates my compiling issue. How would this issue be resolved?
Thanks for your time
EDIT
Undefined symbols for architecture x86_64: "Animal::shout()", referenced from: _main in test-5f7f84.o "Animal::Animal()", referenced from: _main in test-5f7f84.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
g++ animal.cpp test.cpp. You need to compile all source files.