Must be honest, I am getting confused between what keywords go in the function (and sometimes data member) declarations in the header file, versus what goes in the implementation file.
What is the set of rules to follow? For example
(Updated per comments)
- Header files don't contain implementation except if the function is declared as "inline"
- Data members don't contain a default value, unless if the type is static, const, int/enum (unless C++11)
- Public/private/protected usually appear in the header file
- "Static" usually appears in the header file, not the implementation file.
Are thee any other rules I can use to follow? Const?
What about for inheritance? I presume "virtual" only goes in header files? If I inherit virtual functions from Class A into Class B, does the header file of Class B have to declare the virtual functions it overrides? What about a pure virtual function in Class A, when I override in Class B would I have to include the pure virtual function definition in the header file of the derived class?