C++ Error Checking
I want to implement a class and say for each of the method I add code for error checking (bounds,correct args etc..) However I do want the provide user with an option to disable error checking completely and when the user chooses this option the code for error checking shouldn't be executed. I could only think of conditional compilation adding a #ifdefs etc..
What would be the best way to achieve this ?
Just to clarify my case more:-
I would want something similar to
Any suggestions would be really appreciated.
Do you want the checks to be removed at compile time or at run time?
If compile time i am guessing we would have to use conditional compilation.
How about runtime ?
Without much information I cannot guide you well, but all I can say is to drop error codes (if it is possible, that is, it is within your application) and use exceptions instead. You should always check return codes for functions and process them in the right way. Finally, output some error messages if the user requested them.