1. If I have to put class declarations in my own header file, and the actual implementation in another file?
You can write the class definition and the definition of class members separately in the same header file if you are manipulating templates. Also, if you want your members to function in a string, you can define them inside the class definition itself. In any other case, it is better to separate the class definition (.hpp file) and the class member definition (.cpp).
2. If I have to put the headers, as in the example.h file, or in the example.cpp file?
It depends on whether you need these headers in the example.h file or only in your .cpp file.
3.If all classes should use, and I include the class header file in another class header, does this mean that I am included twice?
This happens if you do not complete the definition of your class with the following macros:
#ifndef FOO_HPP #define FOO_HPP class { ... }; #endif
5.If I use many STL classes, what is good practice for using std ::?
I think it's better when you can use std:: every time instead of using namespace std . This way you will only use the namespaces that you need, and your code will be more readable because you will avoid namespace conflicts (imagine two methods that have the same name and belong to two different namespaces).
But most importantly, where is question number 4 anyway?
Amokrane chentir
source share