C++ 생성자

|

C++pasted 1 second ago: 
class NeedConstructor
{
public:
	const int maxCount;
	int& ref;
	int sample;
};

int main()
{
	NeedConstructor cr;

	cr.maxCount = 100;
	cr.ref = cr.sample;

	return 0;
}

class NeedConstructor
{
public:
	const int maxCount;
	int& ref;
	int sample;

	NeedConstructor();
};

NeedConstructor::NeedConstructor()
{
	maxCount = 100;
	num = sample;
}

int main()
{
	NeedConstructor cr;

	return 0;
}

class NeedConstructor
{
public:
	const int maxCount;
	int& ref;
	int sample;

	NeedConstructor();
};

NeedConstructor::NeedConstructor()
	: maxCount(100), ref(sample)
{
	sample = 200;
}

int main()
{
	NeedConstructor cr;

	cout << "cr.maxCount = " << cr.maxCount << "\n";
	cout << "cr.ref = " << cr.ref << "\n";

	return 0;
}



-end

'C++' 카테고리의 다른 글

다중 상속의 문제점  (0) 2010.08.16
생성자와 소멸자  (0) 2010.08.13
c++ 오버라이딩  (0) 2010.07.03
동적 할당 0614  (0) 2010.06.14
c++ 0610  (0) 2010.06.10
And