Chatty Class

This class has output everywhere, announcing construction, destruction, and changes.

#include <iostream> #include <memory> using namespace std; class Chatty { public: Chatty() { cout << "Creating chatty empty" << endl; m_val = 0; } Chatty(int v) { cout << "Creating chatty " << v << endl; m_val = v; } Chatty(const Chatty &c) { cout << "Copying chatty " << c.m_val << endl; m_val = c.m_val; } Chatty &operator=(const Chatty &c) { cout << "Assigning chatty " << c.m_val << " to " << m_val << endl; m_val = c.m_val; } ~Chatty() { cout << "Destroying chatty " << m_val << endl; } int val() const { return m_val; } void set(int v) { cout << "Setting chatty " << m_val << " to " << v << endl; m_val = v; } private: int m_val; };