What compiler are you using? If you're using Visual Studio or Xcode, it should include the implementation automatically, if it's in the same directory.
Try using the Terminal application or the command line (if you aren't already), and use this template command:
c++ -std=c++2a -g -o exec main.cpp implementation.cpp
g++ -std=c++2a -g -o exec main.cpp implementation.cpp
: The clang++ compiler for compiling C++ programs.
: The GNU++ compiler for C++ programs.
: Tells the compiler to use the C++20 standard. You can also try c++2b instead of c++2a for a more recent version.
: Tells the compiler to create a special file for debugging; if you aren't planning on debugging it, you can omit this flag.
: Tells the compiler to name the executable "exec". If you omit this flag, it will default to "a.out".
: Your driver program (main).
: Your class implementation.
There are various other flags you can insert, like -Wall
, and -pedantic
, those are for enabling warnings that wuldn't normally be shown.