Christian: replacing '&' with '*' will help. -best, Pasha Christian Hansen wrote: > > Hi everybody, > > I have a problem using TVector2. In the attached program I want the value > of the vector 'v1' to change after have used the operator '-=', but as u > can see if you run the program nothing happens. Ofcourse this is just a > stupid pointer-referens misstake made by me, but all other ways with the > pointers and references I've tried have just given me the error message > > *** Break *** segmentation violation > > or something similar. > If anyone could found out the correct way to use TVector2 in my program I > would be very glad. > > Cheers > / Christian Hansen > > ---------------------------------------------------------------------------------------------------------------------------------- > # include <math.h> > # include <iostream.h> > > gSystem->Load("libPhysics"); > > void test() { > TVector2 *v1 = new TVector2(4, 2); > TVector2 *vunit1 = new TVector2(0,0); > *vunit1 = v1->Unit(); > cout << "Before Vx = " << v1->X() << endl; > &v1 -= &vunit1; > cout << "After Vx = " << v1->X() << endl; > }
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:58 MET