Anton Fokin wrote:
> pointer (un)initialization was definitely my mistake. The problem is that my
> mistake causes different results on NT and Linux. On Linux the code below
> doesn't produce any error because if you call
>
> A *p = new A();
> p->Draw();
>
>
> libNew zeroes fGraph. On Win98 and ROOT 3.02 it happens so that fGraph is
> not initialized wth zero.
Right. And if on Linux you did, inside some function:
A a; // Define a local A object. Calls the default constructor.
a.Draw();
you are also likely (though not guaranteed) to see a segmentation
violation, for the exact same reason, which is why libNew doesn't buy
you any real safety.
George Heintzelman
georgeh@aya.yale.edu
> class A : public TObject {
> private:
> TGraph *fGraph;
> public:
> A();
> void Draw(const char* Option);
> };
>
> A::A()
> {
> }
>
> void
> A:Draw(const char* Option)
> {
> if (!fGraph)
> fGraph = new TGraph();
>
> ...
>
> fGraph->Draw();
> }
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:34 MET