#include <iostream>
// 연산자 오버로딩
class String
{
private:
	char* m_pStr;			
	int		m_MaxLength;
	int		m_Length;		
public:
	int Length()
	{
		return m_Length;
	}
	const char* GetStr()
	{
		return m_pStr;
	}
public:
	void operator = (const char* _str)
	{
	}
	String operator+ (String _string)
	{
		return String();
	}
	void operator +=(const char* _Str)
	{
	}
public:
	String()
		: m_pStr(nullptr)
		, m_MaxLength(10)
		, m_Length(0)
	{
		m_pStr = (char*)malloc(sizeof(char) * (m_MaxLength + 1));
	}
	~String()
	{
		if (nullptr != m_pStr)
			free(m_pStr);
	}
};
int main()
{
	String str;
	str = "abc";
	return 0;
}	void operator = (const char* _str)
	{
		int len = 0;
		while ('\0' != _str[len]) { ++len; } // 1
		if (m_MaxLength < len) // 2
		{
			Realloc();
		}
		int i = 0;
		for (; i < len; ++i) // 3
		{
			m_pStr[i] = _str[i];
		}
        
		m_pStr[i] = '\0'; // 4
		m_Length = len; // 5
// 기존까지 만든 클래스 생략.
int main()
{
	String str;
    str = "abcdef" 				// 1
    str.operator=("abcdef");	// 2
    
	String str 2 = "hello"; 	// 3
    
    return 0;
}class CTest
{
private:
	int m_i;
public:
	void operator = (int i)  // 3
	{
		this->m_i = i;
	}
public:
	CTest() {}
	CTest(int _i) // 5
		: m_i(_i)
	{}
	~CTest() {}
};
int main()
{	
	CTest t; // 1
  	t = 10; // 2
 
    CTest t = 10; // 4
}	String(const char* _str)
		: m_pStr(nullptr)
		, m_MaxLength(10)
		, m_Length(0)
	{
		m_pStr = (char*)malloc(sizeof(char) * (m_MaxLength + 1));
		(*this) = _str; // 1
	}	String str 2 = "hello";class CQuest
{
private:
	int m_i;
public:
	void operator = (int i)
	{
		m_i = i;
		printf("대입 연산자\n");
	}
public:
	CQuest()
		: m_i(0)
	{
		printf("기본 생성자\n");
	}
	CQuest(int i)
		: m_i(i)
	{
		printf("생성자 호출\n");
	}
};
int main()
{
    CQuset q1;			// 1
    CQuset q2 = 10;		// 2
    
	return 0;
}
	// 대입 연산 구현 생략.
    String operator+ (const String* _string)
	{
		this;
        _string
	}
	int main()
	{
		String str1;
		str1 = "abcdef";
    
		String str2 = "gh";
    
		String str3 = str1 + &str2  // 1
		return 0;
	}int a, b, c;
c = a + &b;String operator+ (const String& _string)	String operator+ (const String& _string)
	{
		String strNew;
		strNew = this->m_pStr;		// 1
		strNew += _string.m_pStr;	// 2
		return strNew;				// 3
	}
    
    int main()
	{
		String str1;
		str1 = "abcdef";
    
		String str2 = "gh";
    
		String str3 = str1 + str2  // 1
		return 0;
	}	void operator +=(const char* _Str)
	{
		// 3
		int len = 0;
		while ('\0' != _Str[len]) { ++len; }
		// 4
		while (m_MaxLength < m_Length + len)
		{
			Realloc();
		}
		// 5
		for (int i = 0; i < len; ++i)
		{
			m_pStr[i + m_Length] = _Str[i];
		}
		// 6
		m_Length += len;
        // 7 
		m_pStr[m_Length] = '\0';
	}
    
    int main()
	{
		String str1;
		str1 = "abc";		// 1
		str1 += "kkk";		// 2
		String str2 = "gh";
		String str3 = str1 + str2;
		printf("%s\n", str3.GetStr());
    	return 0;
	}
private: // 1
	void Realloc()
	{
		m_MaxLength *= 2.f; // 2
		char* pNew = (char*)malloc(sizeof(char) * m_MaxLength); // 3
		for (int i = 0; i < m_Length; ++i) // 4
		{
			pNew[i] = m_pStr[i]; 
		}
		pNew[m_Length] = '\0'; // 5
		free(m_pStr); // 6
		m_pStr = pNew; // 7
	}
#include <iostream>
class String
{
private:
	char* 	m_pStr;			
	int		m_MaxLength;	
	int		m_Length;		
public:
	int Length()
	{
		return m_Length;
	}
	const char* GetStr()
	{
		return m_pStr;
	}
private:
	void Realloc()
	{
		m_MaxLength *= 2.f;
		char* pNew = (char*)malloc(sizeof(char) * m_MaxLength);
		for (int i = 0; i < m_Length; ++i)
		{
			pNew[i] = m_pStr[i];
		}
		pNew[m_Length] = '\0';
		free(m_pStr);
		m_pStr = pNew;
	}
public:
	void operator = (const char* _str)
	{
		int len = 0;
		while ('\0' != _str[len]) { ++len; }
		while (m_MaxLength < len)
		{
			Realloc();
		}
		int i = 0;
		for (; i < len; ++i)
		{
			m_pStr[i] = _str[i];
		}
		m_pStr[i] = '\0';
		m_Length = len;
	}
	String operator+ (const String& _string)
	{
		String strNew;
		strNew = this->m_pStr;
		strNew += _string.m_pStr;
		return strNew;
	}
	String operator+ (const char* _Str)
	{
		String strNew;
		return strNew;
	}
	void operator +=(const char* _Str)
	{
		int len = 0;
		while ('\0' != _Str[len]) { ++len; }
		while (m_MaxLength < m_Length + len)
		{
			Realloc();
		}
		for (int i = 0; i < len; ++i)
		{
			m_pStr[i + m_Length] = _Str[i];
		}
		m_Length += len;
		m_pStr[m_Length] = '\0';
	}
    
public:
	String()
		: m_pStr(nullptr)
		, m_MaxLength(10)
		, m_Length(0)
	{
		m_pStr = (char*)malloc(sizeof(char) * (m_MaxLength + 1));
	}
	String(const char* _str)
		: m_pStr(nullptr)
		, m_MaxLength(10)
		, m_Length(0)
	{
		m_pStr = (char*)malloc(sizeof(char) * (m_MaxLength + 1));
		(*this) = _str;
	}
	~String()
	{
		if (nullptr != m_pStr)
			free(m_pStr);
	}
};
class CQuest
{
private:
	int m_i;
public:
	void operator =(int i)
	{
		m_i = i;
		printf("대입 연산자\n");
	}
public:
	CQuest()
		: m_i(0)
	{
		printf("기본 생성자\n");
	}
	CQuest(int i)
		: m_i(i)
	{
		printf("생성자 호출\n");
	}
};
int main()
{
	String str1;
	str1 = "abc";
	str1 += "kkk";
	String str2 = "gh";
	String str3 = str1 + str2;
	printf("%s\n", str3.GetStr());
	String str4 = "hello";
	CQuest q1;
	CQuest q2 = 10;
	return 0;
}1차 23.12.22
2차 23.12.25
3차 23.12.26
4차 23.12.27
5차 23.12.28
6차 24.01.02