Skip to content

Instantly share code, notes, and snippets.

@Manu343726
Last active March 9, 2017 12:42
Show Gist options
  • Select an option

  • Save Manu343726/a9747e87abea6ab79937cd80f1701091 to your computer and use it in GitHub Desktop.

Select an option

Save Manu343726/a9747e87abea6ab79937cd80f1701091 to your computer and use it in GitHub Desktop.

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:

  • 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.

References

Based on Manu343726/C--#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment