#include <iostream>
using namespace std;

int count = 0;

class Sample {
    int *p;
    int q;
    int m_count;

public:
    Sample() {
        m_count = count;
        cout<<"Constructor called for m_count = "<< count++ << endl;

        p = new int;
        q = 0;
    }

    Sample& operator =(const Sample &rhs) {
        cout<<"Assignment Operator (m_count " << m_count << " = m_count " << rhs.m_count << ") " <<endl;
        if(this != &rhs)
        {
            delete p; // Unnecessary
            p = new int; // Unnecessary
            *p = *(rhs.p);
        }
        return *this;
    }
};

int main() {
  Sample a;
  Sample b;
  Sample c;

  a = (b = c); // (b = c) will return a Sample&
}