I'm sure that the display member should not modify the contents of the object... so your display function should be called something like corruptAndDisplay()
I'm sure that the display member should not modify the contents of the object... so your display function should be called something like corruptAndDisplay()
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
Im really not getting what u mean? Are u saying that my member functions are changing the contents. Should I use & as like a reference?
I mean the function should do what the name suggests
display function should display current contents and should not modify the object
your function effectively modifies the object - so it is wrong on this state already
declare it as a const and see the compilation errors you get
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler