#include <iostream>
#include <cstring>
using namespace std;

const int MAXLEN = 80;

class STR {
	char string[MAXLEN];
public:
	 STR(const char *s = "");
	 STR(const STR & s);
	STR operator=(STR s);
	STR operator=(const char *cs);
	STR operator+(STR s);
	STR operator+(const char *cs);
	friend STR operator+(const char *cs, STR s);
	void show();
};

STR::STR(const char *s)
{
	cout << "[cnstr] ";
	strcpy(string, s);
}

STR::STR(const STR & s)
{
	cout << "[cpycnstr] ";
	strcpy(string, s.string);
}

STR STR::operator=(STR s)
{
	cout << "[=obj] ";
	strcpy(string, s.string);
	return *this;
}

STR STR::operator=(const char *cs)
{
	cout << "[=cs] ";
	strcpy(string, cs);
	return *this;
}

STR STR::operator+(STR s)
{
	cout << "[+obj] ";
	STR temp;
	strcpy(temp.string, string);
	strcat(temp.string, s.string);
	return temp;
}

STR STR::operator+(const char *cs)
{
	cout << "[+cs] ";
	STR temp;
	strcpy(temp.string, string);
	strcat(temp.string, cs);
	return temp;
}

STR operator+(const char *cs, STR s)
{
	cout << "[cs+] ";
	STR temp;
	strcpy(temp.string, cs);
	strcat(temp.string, s.string);
	return temp;
}

void STR::show()
{
	cout << string << endl;
}

int main()
{

	// [cnstr] Hello world.
	{
		// [cnstr]
		STR s1("Hello world.");

		s1.show();
	}

	// [cnstr] [cpycnstr] [cpycnstr] [=obj] [cpycnstr] Hello world.
	{
		// [cnstr]
		STR s1 = "Hello world.";

		// [cpycnstr]
		STR s2 = s1;

		// [cpycnstr] [=obj] [cpycnstr]
		s2 = s1;

		s2.show();
	}

	// [cnstr] [cnstr] [cnstr] [cpycnstr] [=obj] [cpycnstr] [=obj] [cpycnstr] Hello world.
	// Hello world.
	// Hello world.
	{
		// [cnstr]
		STR s1("Hello world.");

		// [cnstr] [cnstr]
		STR s2, s3;

		// [cpycnstr] [=obj] [cpycnstr] [=obj] [cpycnstr]
		s3 = s2 = s1;

		s1.show();
		s2.show();
		s3.show();
	}

	// [cnstr] [cnstr] [=cs] [cpycnstr] [=obj] [cpycnstr] Hello world.
	// Hello world.
	{
		const char s1[] = "Hello world.";

		// [cnstr] [cnstr]
		STR s2, s3;

		// [=cs] [cpycnstr] [=obj] [cpycnstr]
		s3 = s2 = s1;

		s2.show();
		s3.show();
	}

	// [cnstr] [cnstr] [cnstr] [cpycnstr] [+obj] [cnstr] [=obj] [cpycnstr] Hello world.
	{
		// [cnstr]
		STR s1("Hello ");

		// [cnstr]
		STR s2("world.");

		// [cnstr]
		STR s3;

		// [cpycnstr] [+obj] [cnstr] [=obj] [cpycnstr]
		s3 = s1 + s2;

		s3.show();
	}

	// [cnstr] [cnstr] [+cs] [cnstr] [=obj] [cpycnstr] Hello world.
	{
		// [cnstr]
		STR s1("Hello ");

		const char s2[] = "world.";

		// [cnstr]
		STR s3;

		// [+cs] [cnstr] [=obj] [cpycnstr]
		s3 = s1 + s2;

		s3.show();
	}

	// [cnstr] [cnstr] [cpycnstr] [cs+] [cnstr] [=obj] [cpycnstr] Hello world.
	{
		const char s1[] = "Hello ";

		// [cnstr]
		STR s2("world.");

		// [cnstr]
		STR s3;

		// [cpycnstr] [cs+] [cnstr] [=obj] [cpycnstr]
		s3 = s1 + s2;

		s3.show();
	}

	return 0;
}