I recently found a bug in one of my programs... and it's disturbing to me, so I'd like some comments.
Suppose I have a function which takes QString as an argument, and I don't change the value of the argument in the function, so I set it as const (is that what const means by the way?... that the function is not allowed to change the value of it?).
But the function happened to be recursive, and it called itself with another value of the parameter. This caused UNEXPECTED BEHAVIOR! I can't describe exactly what happens, but the values changed right in the middle of the function!
Qt Code:
... QString val2=...; ... myfunction(val2); [Here's where val changed!] ... }To copy to clipboard, switch view to plain text mode
Am I misunderstanding something?
Bookmarks