Ask your AI Ask your AI to turn this code into a guided bug-finding exercise.
Claude ChatGPT I am reading "Why should a member function that only reads object state usually have a trailing const?" on CodeWiki (https://codewiki.com/practice/mcq/cpp/classes/const-observer/).
Context (verbatim from the page):
"""
Why should a member function that only reads object state usually have a trailing const?
It can be called through const objects and prevents ordinary mutation through this.
It makes every returned reference safe after the object is destroyed.
It guarantees the function is thread-safe.
It forces the compiler to evaluate the function at compile time.
"""
Introduce three subtle bugs into the example above and let me find them. Reveal each answer only after I have guessed.
Answer in English. Keep code examples in C++. Where you are unsure, say so.