Enums: Can they do in .h or must stay in .cpp?

A .h file is essentially just code which, at compile time, is placed above any .cpp (or .h file for that matter) that it’s included in. Therefore you CAN just place any code from the .cpp file into the .h and it should compile fine.

However it’s the design which is important. Your code (e.g. your enum) SHOULD be placed in the .h file if you need to expose it to the code you’re including the .h file. However if the enum is only specific to the code in your header’s .cpp implementation, then you should encapsulate it just within the .cpp file.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)