Esempio n. 1
0
int main()
{
	//ConcreteAggregate *pName = NULL;
	ConcreteAggregate *pName = new ConcreteAggregate();
	if(NULL != pName)
	{
		pName->Push("Hello");
		pName->Push("word");
		pName->Push("kevin");
	}

	Iterator *iter = NULL;
	iter = pName->CreateIterator();
	if(NULL != iter)
	{
		string strItem = iter->First();
		while(!iter->IsEnd())
		{
			cout << iter->GetCur() << " is ok " << endl;
			iter->Next();
		}
	}

	delete pName;

	return 0;
}
Esempio n. 2
0
int main()
{
    ConcreteAggregate<int> a;
    a.PushBack(1);
    a.PushBack(2);
    a.PushBack(3);
    a.PushBack(4);

    Iterator<int> *iter = a.CreateIterator();
    iter->First();
    while(iter->IsDone() == false)
    {
        std::cout << iter->CurrentItem() << std::endl;
        iter->Next();
    }
    return 0;
}