E D R , A S I H C RSS

Constructor Parameter Method

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;
	}
/* ... */
};

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:00
Processing time 0.0092 sec