To code with assertions considers good style of coding.
As for runtime turning on/off You may do that with Boolean variable. For example in your code you can do the following:
Define a variable which will be used to indicate if assertions are turned on or off in a global namespace (for example out of your main() function in the same file).
bool turnOnAssertions;
Define a variable as written below in other files where you want to turn on/off your assertions:
extern bool turnOnAssertions;
So by manipulating the turnOnAssertions variable with the UI and writing
if(turnOnAssertions)
assert(…);
you can turn on/off some of you assertions!
As for compile time you should do the following:
For you compiler you should give a flag like –DASSERTIONSON (-Dflag_name [flag name you can set anything you want])
#ifdef ASSERTIONSON
bool turnOnAssertions = true;
#else
bool turnOnAssertions = false;
#endif
And just use the variable.
Good luck!