vector of structs?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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

.