C++¿¡¼­ ŸÀÔ Ä³½ºÆà ¿¬»êÀÚ ¿Àºê ·Îµù¿¡ ´ëÇؼ­ ¾Ë¾Æ º¸°Ú½À´Ï´Ù.

º¯È¯ ÇÔ¼ö´Â  »ç¿ëÀÚ ÀúÀÇ Çü º¯È¯°ú ºñ½ÁÇÑ ÇüÅÂ·Î½á ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÒ¼ö ÀÖ½À´Ï´Ù.

TestClass test(1, 6, 3);
int  a1 = int (test);   //¸í½ÃÀûÀÎ ¹æ¹ý
int  a2 = (int) test;

int  a3 = test;            //¾Ï½ÃÀûÀÎ ¹æ¹ý

º¯È¯ÇÔ¼öÀÇ ±âº»ÀûÀÎ ÇüÅ´ ´ÙÀ½°ú °°½À´Ï´Ù.

operator typename();

¾Æ·¡ »çÇ×À» ±â¾ïÇØ¾ß ÇÕ´Ï´Ù.
 1)º¯È¯ ÇÔ¼ö´Â Ŭ·¡½ºÀÇ ¸Þ¼ÒµåÀ̾î¾ß ÇÑ´Ù.
 2)º¯È¯ ÇÔ¼ö´Â ¸®ÅÏÇü¸¦ ÁöÁ¤ÇÏÁö ¾Ê´Â´Ù.
 3)º¯È¯ ÇÔ¼ö´Â Àü´ÞÀÎÀÚ¸¦ °®Áö ¾Ê¾Æ¾ß ÇÑ´Ù.

  
¾Æ·¡ ¿¹Á¦¸¦ º¸¼¼¿©.....

#include 

class TestClass 
{
public:
	TestClass (double x, double y, double z) {m_x = x;  m_y = y; m_z = z;};
    
	//º¯È¯ ÇÔ¼ö 
	operator int() const;


private:
	double m_x;
	double m_y;
	double m_z;
};

TestClass::operator int() const
{
    int ret = (int)(m_x + m_y + m_z);
	return ret;
}

void main(void)
{
    TestClass test(1, 6, 3);

	int k = test;
	cout << endl <<"Result? "<< k << endl;	
}

end...............

    È¨À¸·Î     À妽º·Î