Constructor Parameter Method ¶
Constructor Method��� ��������������� ���������, ��������� ��������� 파��������������� ��������� ������������ ��������������� ��������� ������ ���������? ������ ������한 ��������� ��������� ��������� ���해 setter������ ��������� ������ ���������. ���,
~cpp class Point { /* ... */ void setX(int x) { /* ... */ } void setY(int y) { /* ... */ } static Point* makeFromXnY(int x, int y) { Point* pt = new Point; pt->setX(x); pt->setY(y); return pt; } /* ... */ };��������� ���������������. 하������ ��������� ��������������� setter������ ������ ������������. ��������������� ������ ��������� 한������ set해������ 하������ ������������ ���������. ��������� ������������ set������ ������해������ ��������� ��������� ������������.
~cpp class Point { /* ... */ static Point* makeFromXnY(int x, int y) { Point* pt = new Point; pt->setXnY(x,y); return pt; } void setXnY(int x, int y) // smalltalk��������� setX:xNum y:yNum��������� ������������ ������한���. { this->x = x; this->y = y; } /* ... */ };