Roberto64_Ge wrote:main.cpp includes header.cpp which includes header.h
This is probably the source of your problem. Visual Studio is probably compiling header.cpp and creating a separate object file, then compiles main.cpp, which includes header.cpp, and so creates two copies of the methods defined in header.cpp. In general it is a mistake to
#include a cpp file in another cpp file. You main.cpp only needs to include header.h, which should only provide a declaration of your class. You would then compile main.cpp and header.cpp separately.
You can do this on the ubuntu command line using
g++ -Wall -Wextra main.cpp header.cpp -o main or alternatively
g++ -Wall -Wextra -c main.cpp
g++ -Wall -Wextra -c header.cpp
g++ main.o header.o -o main In the above example, the
-c option to g++ tells the compiler to only produce an intermediate object file (e.g. a .o file), and not try to produce an executable. The third line creates the final executable, and includes all the system libraries and startup code needed for the executable.
Keep Calm and Carry On