The objective of this exercise is to learn the basics of RAII, the most important pilar of C++. To do so, you must implement an inmutable string class, which works as follows:
The class belongs to the first module of the project, containers.
Can be initialized from a C null terminated string (const char*).
Manages its own copy in memory of the string given to the constructor.
The underlying string storage is correctly handled (Released when it needs to, copied when it needs to, etc).
The class has no mutable operations, so the underlying storage is modified only in initialization/copy/move/destruction operations.
Bonus points:
Run a memory checker, such as Valgrind, on your unit tests and make sure there are no memory leaks.
Provide conversion operations from/to std::string.
A readonly string class
The objective of this exercise is to learn the basics of RAII, the most important pilar of C++. To do so, you must implement an inmutable string class, which works as follows:
containers
.const char*
).Bonus points:
std::string
.References