[Insight-users] array of SmartPointer

Miller, James V (Research) millerjv at crd.ge.com
Wed Mar 16 09:48:42 EST 2005


You can use an std::vector<T> where T is a SmartPointer to an object.  This is done 
frequently in ITK.
 
In terms of debugging, you'll have to us more information on the how the program is crashing (call stack, etc.) in order for us to provide more information.
 
Jim

-----Original Message-----
From: insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org]On Behalf Of bertrand
Sent: Wednesday, March 16, 2005 9:19 AM
To: itkusers
Subject: [Insight-users] array of SmartPointer


Hello all,

I would to how if there is a way to create an array of SmartPointer and if there is one, how to do that.
Actually I'm looking for writing a class in which I'd like to store some SmartPointer in an array
For example in the header of the class, I have something like :

        typedef GaussianDensityFunction< MeasurementVectorType >              DensityComponantType;
        typedef DensityComponantType::Pointer                                                  DensityComponantPointer;

In this class I use an attribute:

        DensityComponantPointer *        m_GaussianComponents;


I would like this attribute to be an array where I could store a set of  N * DensityComponantPointer
I've tried  to write something like :

    unsigned int size = m_List->Size();
    m_GaussianComponents  = new DensityComponantPointer[size];

    for ( unsigned int s = 0; s < size; s++ ) 
        {  
        this->m_GaussianComponents[size] = DensityComponantType::New();
         }

in my *.txx* file but I get a  unhandled  execption when debugging it 
Is there a way to resolve it ??

Bertrand
   


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050316/12b05b2d/attachment.htm


More information about the Insight-users mailing list