Re: [ROOT] zero pointers on NT

From: Anton Fokin (anton.fokin@smartquant.com)
Date: Fri Jan 26 2001 - 11:13:15 MET


Well,

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.

Anyhow, thanks to Win98, I have corrected my knowledge about pointer
initialization. Actually people are quite right, libNew and automatic
zeroing are quite dangerous. I was 100% sure I have read in the last edition
of Stroustrup that all pointers set to zero at initialization. With libNew I
could misslead myself for the rest of my life.

Regards,
Anton

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