← The Rule of Three (and Five) & RAII

A Complete RAII Message Class

medium

Message owns a char * – a raw, manually-managed C-string, deliberately built the Module-2 way rather than with std::string, so the Rule of Three genuinely applies. Add the destructor, copy constructor, and copy assignment operator together, as one unit – exactly the lesson’s point, not three separate problems to solve independently.

main exercises all three at once: b is created via the copy constructor, c is overwritten via copy assignment, and every object is destroyed at the end whether it’s main’s implicit return or the program simply ending – if any one of the three is wrong or missing, expect either wrong output (a mutation through b leaking into a or c) or a crash.

Your solution

"Run" uses the sample stdin ("hello"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution