[vtkusers] syntax question

A J lost_bits1110 at hotmail.com
Tue Jun 8 16:08:09 EDT 2004


OKAY I'm retarded I got it finally!!
So here's how you go about it:


vtkBclass **Stuff = new (vtkBclass *)[20];
for (int i=0; i<20; i++)
	Stuff[i] = vtkStuff::New();

Stuff[5]->HelloWorld();

cout<<"hello world completed"<<endl;









>I'm surprised it works at all... Stuff[1] through Stuff[19]
>won't be memory you own, and yet it is assigned to.
>
>what does the debugger say it is crashing on?
>
>I' m guessing you are in a Windows environment. I'm not very
>familiar with Windows but I know that UNIX libc implementations
>almost always have an environment variable you can set to allow
>you to debug malloc() calls (MALLOC_CHECK_ on linux,
>MALLOC_OPTIONS on freebsd, etc.). Perhaps there is a similar
>mechanism available on Windows?
>You may wish to try setting it and see if its an allocation
>issue...
>
>-tom
>
>  <BAY99-F64sQPwFpH2cX000036f3 at hotmail.com>"A J" writes:
> >Okay I almost have it... but I get a 'segmentation fault' at the end:
> >
> >vtkBclass **Stuff;
> >for (int i=0; i<20; i++)
> >	Stuff[i] = vtkBclass::New();
> >
> >Stuff[0]->HelloWorld();
> >
> >.. and then it crashes after it finishes executing the HelloWorld
> >function.....
> >!!!!
> >
> >so close but no cigar..!!  :o(
> >
> >
> >
> >
> >>Oh hrm, I seem to have totally glazed over that you were
> >>trying to allocate an array... Sorry 'bout that.
> >>
> >>Interesting question. Perhaps
> >>
> >>vtkBclass **stuff = vtkBclass::New()*[number]
> >>
> >>would do what you wanted?
> >>
> >>Just a stab in the dark.. I'll be interested to hear the
> >>solution.
> >>
> >>-tom
> >>
> >>  <BAY99-F53CTVuy16xso0000c978 at hotmail.com>"A J" writes:
> >> >Yes thanks tom , I've already inherited these from vtkObject,
> >> >but now this means that instead of doing
> >> >
> >> >Bclass *stuff = new Bclass[ number ]
> >> >
> >> >I now have to do something like
> >> >
> >> >vtkBclass **stuff = vtkBclass::New() [number]
> >> >
> >> >or...???
> >> >
> >> >I just want a pointer to an array of vtkBclass's, not just one which
> >>would
> >> >obviously just be
> >> >vtkBclass *stuff = vtkBclass::New();
> >> >
> >> >
> >> >
> >> >
> >> >>AJ, use Bclass' New() member function.
> >> >>
> >> >>You should derive Bclass (and Aclass, for that matter) from a
> >> >>vtkObject and it will then automagically obtain the vtkObject::New()
> >> >>member function.
> >> >>
> >> >>Also, you should make sure your vtk* objects have their constructors
> >> >>and destructors declared as protected, and additionally that the
> >> >>destructors are declared virtual.
> >> >>
> >> >>HTH,
> >> >>
> >> >>-tom
> >> >>
> >> >>  <BAY99-F504GCjNNsqlt0003748a at hotmail.com>"A J" writes:
> >> >> >Hi,
> >> >> >
> >> >> >Say I have my own classes called Aclass and Bclass
> >> >> >
> >> >> >and say I have now wrapped these to VTK classes so they are now 
>known
> >>as
> >> >> >vtkAclass and vtkBclass
> >> >> >
> >> >> >Originally, I had:
> >> >> >
> >> >> >class Aclass
> >> >> >{
> >> >> >
> >> >> >public:
> >> >> >Bclass *stuff = new Bclass[ number ]
> >> >> >  ....
> >> >> >}
> >> >> >
> >> >> >
> >> >> >So now that Aclass has become vtkAclass and same for vtkBclass.. 
>what
> >>is
> >> >>the
> >> >> >syntax to do this with the New() operator that I now have to use..? 
>  I
> >> >>had
> >> >> >tried a few things but nothign works so far.. it must be something
> >>very
> >> >> >basic..! =S
> >> >> >
> >> >> >Thanks!!
> >> >> >
> >> >> >_________________________________________________________________
> >> >> >Watch the online reality show Mixed Messages with a friend and 
>enter
> >>to
> >> >>win
> >> >> >a trip to NY
> >> >>
> >> 
> >http://www.msnmessenger-download.click-url.com/go/onm00200497ave/direct/01/
> >> >> >
> >> >> >_______________________________________________
> >> >> >This is the private VTK discussion list.
> >> >> >Please keep messages on-topic. Check the FAQ at:
> >> >><http://public.kitware.com/cgi-bin/vtkfaq>
> >> >> >Follow this link to subscribe/unsubscribe:
> >> >> >http://www.vtk.org/mailman/listinfo/vtkusers
> >> >
> >> >_________________________________________________________________
> >> >Is your PC infected? Get a FREE online computer virus scan from 
>McAfee®
> >> >Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> >> >
> >> >_______________________________________________
> >> >This is the private VTK discussion list.
> >> >Please keep messages on-topic. Check the FAQ at:
> >><http://public.kitware.com/cgi-bin/vtkfaq>
> >> >Follow this link to subscribe/unsubscribe:
> >> >http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >_________________________________________________________________
> >FREE pop-up blocking with the new MSN Toolbar – get it now!
> >http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

_________________________________________________________________
MSN Toolbar provides one-click access to Hotmail from any Web page – FREE 
download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/




More information about the vtkusers mailing list