/**
 *   ~~~~~ One argument constructor with operator overloading ~~~~~
 * 
 * Demonstrates which is called when, when both overloaded assignment operator
 * and one-argument constructor is defined.
 * 
 * Observation: During object creation, one argument constructor is called, while during
 * object assignment, operator function is called.
 */

#include <iostream>
using namespace std;

class A{

private:
	static int a;
public:
	A(int);
	void print();
	static void operator =(int);
};

// Allocation for static
A::a;

// One argument constructor
A::A(int b){
	cout<<"Inside one argument constructor"<<endl;
	this->a=b;
}

static void A:: operator =(int b){
	cout<<"Inside operator function"<<endl;
	this->a = b;
}

void A::print(){
	cout<<"Value of a ="<<a<<endl;
}

int main() {
	
	/* INITIALIZATION */
	A obj1=2;
	obj1.print();
	
	/* ASSIGNMENT */
	obj1=3;
	obj1.print();
	
	return 0;
}