First, notice that you could avoid any application #include
(so only include system headers or headers for external libraries) and just copy & paste source code into several files. That would be inconvenient. Read more about the C preprocessor. Notice that it is mostly doing textual processing (e.g. does not know much about C++ syntax or ASTs).
Then, conventionally, header files contain mostly declarations (of types, struct
, class
, functions, variables, ...) and definitions of static inline
functions (or inline
member functions of your class
-es).
So you'll better not #include "square.cpp"
in your figure.cpp
source file, but just have a single myheader.h
file with a #include "myheader.h"
both in your square.cpp
and your figure.cpp
source files (i.e. translation units).
Read more books about C++ programming and study the source code of some C++ free software, e.g. hun7err's Chess and ChessPlusPlus (I am not expert in chess programming, and found both of them thru quick google searches)