Re: STL error in VC++, missing ';' before '<'
"beyonddoor" <beyonddoor@hotmail.com> ha scritto nel messaggio
news:ezbSidsTIHA.1168@TK2MSFTNGP02.phx.gbl...
I want pList to be processed in the other functions, that's why I create a
pointer pList. Just as Giovanni says, I don't want copy constructors to be
invoked many times, I don't know whether it's worthwhile or not.
If CData is not a very big object, you may consider keeping CData in list,
so having std::list< CData >.
Else, I would suggest to use boost::shared_ptr (or tr::shared_ptr when TR1
will ship as kind of "service pack" for VS2008).
e.g.
typedef std::list< boost::shared_ptr< CData > > ListOfCData;
For more information on boost::shared_ptr, you may read here:
http://www.boost.org/libs/smart_ptr/shared_ptr.htm
For TR1 (and other interesting things) I would suggest to read Visual C++
Team's blog:
http://blogs.msdn.com/vcblog/archive/2007/12/26/just-what-is-this-tr1-thing.aspx
If you want to pass your list between different functions or methods, you
can use pointers or references (I would use references), e.g.
void InitList( ListOfCData & list )
{
// Build your list here.
//
// Whatever modification you do to 'list' instance will be
// made for the caller's list instance, because you are passing by
*reference* (the "&")
}
void DoSomethingOnList( ListOfCData & list )
{
// As before...
list.<some method>
}
ListOfCData myList; // list instance
InitList( myList );
DoSomethingOnList( myList );
Giovanni