vector of structs?
- From: "Jason S" <jmsachs@xxxxxxxxx>
- Date: 27 Apr 2006 13:29:13 -0700
I've used map<T> and vector<T> and such before, where T is a simple
type, but am rather confused about the recommended way of doing it with
structures, especially ones that contain objects as a member. (Like
CComBSTR and CComPtr)
If I have
typedef struct {
short s;
MyClass obj;
CComPtr<something> p;
} X_t;
should I use vector<X_t> or vector<X_t*>? If the former, how do I
handle push_back() with a structure? If the latter, then don't I have
to allocate memory for X_t, in which case, what's the point of using
vector<>? And if I do choose to allocate memory for X_t, I can't just
use malloc/CoTaskMemAlloc(sizeof(X_t)*N), because then how will it
properly initialize the non-simple types contained in X_t like obj()
and p() which might have constructors?
bewildered,
--Jason
.
- Follow-Ups:
- Re: vector of structs?
- From: Brian Muth
- Re: vector of structs?
- From: Igor Tandetnik
- Re: vector of structs?
- Prev by Date: Re: STLPort in VC++ - Compile problems
- Next by Date: Re: vector of structs?
- Previous by thread: STLPort in VC++ - Compile problems
- Next by thread: Re: vector of structs?
- Index(es):