E D R , A S I H C RSS

Collection Parameter

Collecting Parameter

몇몇 메 결과 떻게 리가?(?)

ComposedMethod 나는, 드들 관때문다. , 드들 된다. 가 방법 ComposedMethod고 다 다 때려는 것만, 다. 또 다른 로는 드들 되는 를 멤 는 것다. 명기 라, 드들 될때다. 다.

, 메드들 라메 는 것다. 는 방법나, 다른 것들보단 낫다.

남과 미녀를 내는 드를 보.
~cpp 
vector<People> marriedMenAndUnmarriedWomen()
{
	vector<People> result;
	for(vector<People>::iterator it = result.begin() ; it != result.end() ; ++it)
	{
		if(it->isMarried() and it->isMan())
			result.add(*it);
	}
	for(vector<People>::iterator it = result.begin() ; it != result.end() ; ++it)
	{
		if(it->isUnmarried() and it->isWoman())
			result.add(*it);
	}
	return result;
}
ComposedMethod.
~cpp 
vector<People> marriedMen()
{
	vector<People> result;
	for(vector<People>::iterator it = result.begin() ; it != result.end() ; ++it)
	{
		if(it->isMarried() and it->isMan())
			result.add(*it);
	}
	return result;
}
vector<People> unmarriedMen()
{
	vector<People> result;
	for(vector<People>::iterator it = result.begin() ; it != result.end() ; ++it)
	{
		if(it->isUnmarried() and it->isWoman())
			result.add(*it);
	}
	return result;
}
vector<People> marriedMenAndUnmarriedWomen()
{
	return marriedMen() + unmarriedMen();	// 될 는 모르겠만 된다고 가.
}

말고 각각 .
~cpp 
vector<People> marriedMenAndUnmarriedWomen()
{
	vector<People> result;
	addMarriedMenTo(result);
	addUnmarriedWomenTo(result);
	return result;
}

void addMarriedMen(vector<People>& aCollection)
{
	for(vector<People>::iterator it = result.begin() ; it != result.end() ; ++it)
	{
		if(it->isMarried() and it->isMan())
			aCollection.add(*it);
	}
}
void addUnmarriedMen(vector<People>& aCollection)
{
	for(vector<People>::iterator it = result.begin() ; it != result.end() ; ++it)
	{
		if(it->isUnmarried() and it->isWoman())
			aCollection.add(*it);
	}
}

, 두 메 결과를 모는 경데, 그리 로 기. 다르긴 만 나 CollectionParameter 가 read/write I/O 가 내부때 또는 Serialization 때. 그 경 I/O 부 Stream 로 만들고(C++ Stream 또는 Stream 만들 ) parameter 로 고 그 라메드를 . --1002


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:57
Processing time 0.0177 sec