Say I have a program where the value of an integer i should never be negative. Is there a way I can insert a global assert(i>=0) such that whenever i becomes negative an error is reported. This can be very useful while debugging. I don’t want to put an assert everywhere the value of i is manipulated.
Say I have a program where the value of an integer i should never
Share
No.
Your debugger might have this sort of facility, though. For instance, GDB has watchpoints.