I have started reading C++ and I have a question about classes and member variables of type Enum and Struct. Where should I declare Enums/Structs so that I can use them as member variables when I separate header and implementation file? And also, how can I make a final member variable in a C++ class? I am just getting compilation error when adding const int myTest as a member variable, where should I initialize them?
I have started reading C++ and I have a question about classes and member
Share
The header file is like a person saying ‘I can do this, that and the other’ – so put declarations into it – enums, structs, class declarations, constants, …
The implementation file is like a person saying ‘I can do this and this is how I can do it’ – it produces a recipe – Actual machine code for the CPU to crunch.
constsays – do not change me. To intialise in a class you need:for example. If you are learning about C++
constis a very useful tool to prevent you making a multitude of errors.