In your second and final step, you didn’t instruct the compiler (linker more exactly) to take into account Adder.o
, so your final executable still doesn’t know the implementation of Adder::add
Try, after getting Adder.o, to run g++ main.cpp Adder.o
Also, this may be relevant : Difference between compiling with object and source files
Also, if that is the complete code, as others have pointed out, in the Adder.cpp
, you are just defining a simple function, not the one from the Adder
class.
solved Why am I getting an undefined reference error while using separate .cpp and .h files for a class?