벡터를 사용하였습니다. ^^..
초보자 분들은 꼭 한번씩 돌려보세요 ^^///
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#pragma hdrstop
#include <vector>
#include <boost/any.hpp>
#include <boost/shared_ptr.hpp>
using boost::any_cast;
using boost::shared_ptr;
typedef std::vector<boost::any> many;
//---------------------------------------------------------------------------
class TZPacket
{
public:
TZPacket() {};
AnsiString sayHello() { return AnsiString("Hello!"); }
};
typedef boost::shared_ptr<TZPacket> ZPacket;
typedef boost::any ANY_PARAM;
#pragma argsused
many mylist;
void addElement( ANY_PARAM pElement )
{
mylist.push_back( pElement );
}
ANY_PARAM getElementAt( int iIndex )
{
if( mylist.size() <= iIndex )
{
#ifdef APP_DOUBT
zout.trace("%s%s\n", APP_DOUBT, "TZNormalQueue::getElementAt | FList->Count <= iIndex");
#endif
return NULL;
}
return mylist[iIndex];
}
int main(int argc, char* argv[])
{
ZPacket a( new TZPacket() );
printf("use count : %d\n", a.use_count());
addElement( a );
printf("use count : %d\n", a.use_count());
addElement( a );
printf("use count : %d\n", a.use_count());
addElement( a );
printf("use count : %d\n", a.use_count());
printf( "vlist count = %d\n", mylist.size() );
for( int i = 0; i < mylist.size(); i ++ )
{
printf( "%s\n", any_cast<ZPacket>(getElementAt(i))->sayHello() );
}
system("pause");
return 0;
}
//---------------------------------------------------------------------------
|