Where to put additional libraries (such as ) in .h or .cpp, since it works when defined in each one of them?
It doesn't really matter as long as the parts of your library that need to see the headers can see them. Personally I put all headers in the master .h file and then that gets included in the .cpp file(s). It just keeps it all in one place and is easier to manage.
What is the purpose of defining variables in the :private section? Since they can be defined inside constructor, and as far as I know/tested, it works as well.
You need to understand "scope". Defining a variable inside the constructor means that it's only available within that constructor. This is "local" scope. Defining the variable in the class, within the "private" section makes that variable available to every function within the class. Putting it in "public" makes it available to anyone anywhere.
In a .cpp file, does it matter when instances or variables are defined outside a class (at the beginning of code ), since again, it works the same?
Again this is a matter of "scope". A variable declared outside the class is in "global" scope. There is only one copy of each of these variables, and all instances of the class share the same physical variable. It is the same as declaring a class variable as "static" - it makes it common to all instances of the class. If the data you need to store is specific to a class instance (which most of the time it is), you do not want to use global variables. In general it's bad form using global variables if you don't have to.
Incidentally, you may see variables defined both in the class and at the top of the CPP file. This is a special case where you have static variables in your class, which don't have any storage space allocated to them (normally a variable has its storage space allocated when you create an instance of the class, but that doesn't happen with static variables for obvious reasons), so you have to manually provide the storage space with a separate entry in the CPP file.