After we discuss the concept of immutability, now let's develop the immutable object. We will start with the mutable object first, then refactor it into an immutable one.
Developing the immutable object
Starting with a mutable object
Now, let's go further. We will create another class to design an immutable object. First, we will create a mutable class named MutableEmployee. We have some fields and methods in that class. The header of the class will be like the following piece of code:
/* mutableemployee.h */
#ifndef __MUTABLEEMPLOYEE_H__
#define __MUTABLEEMPLOYEE_H__
#include <string>
class MutableEmployee
{
private:
int m_id;
std::string m_firstName;
std::string...