Distribution of .cpp and .h files
Posted: Sun Feb 19, 2017 12:22 pm
Hi all,
I've been working through the zetcode.com tutorials and am finding them most helpful.
A once blurry picture is starting the form a much clearer picture in my mind, such that I may be able to start writing my own GUI apps in the semi-near future.
One question - I notice that these tutorials break a nominal-length program into 4 or more individual files such as main.h, main.cpp, subject.h, subject.cpp, anotherone.h, anotherone.cpp.
Out of curiosity, I piled all this code into one, long file and it compiled and it ran just fine.
I've noticed that these header files don't even follow the same exact format as C++ header files (e.g. beginning with #ifndef MY_FUNCTION_H
#define MY_FUNCTION_H etc)
So, is there a reason to cut the code up into several files or is this just a preference of the guy who wrote the tutorial?
Many thanks.
I've been working through the zetcode.com tutorials and am finding them most helpful.
A once blurry picture is starting the form a much clearer picture in my mind, such that I may be able to start writing my own GUI apps in the semi-near future.
One question - I notice that these tutorials break a nominal-length program into 4 or more individual files such as main.h, main.cpp, subject.h, subject.cpp, anotherone.h, anotherone.cpp.
Out of curiosity, I piled all this code into one, long file and it compiled and it ran just fine.
I've noticed that these header files don't even follow the same exact format as C++ header files (e.g. beginning with #ifndef MY_FUNCTION_H
#define MY_FUNCTION_H etc)
So, is there a reason to cut the code up into several files or is this just a preference of the guy who wrote the tutorial?
Many thanks.