Instead of using #define or const, I usually define constants using class static methods as follows:
//AppConstants.h
#include <string>
class AppConstants{
public:
static int getMax();
static std::string getPrefix();
};
//AppConstants.cpp
#include "AppConstants.h"
int AppConstants::getMax(){
return 30;
}
std::string AppConstants::getPrefix(){
return "myprefix";
}
I do this usually when creating a mobile app, which I would like to save the compile time when each time change the value for testing. Is it a bad practice?