Re: [ROOT] Two new-user questions regarding tutorial h1draw.C

From: Jiri Masik (masik@pc203b.fzu.cz)
Date: Thu May 18 2000 - 22:48:46 MEST


Charlie Maguire <charles.f.maguire@vanderbilt.edu> writes:

> 	Second question.  If I add a "void h1draw()" line to the original
> version of h1draw.C, and then give the command ".x h1draw.C" all works
> fine for the top 2 plots, but the data points in the bottom plot
> flash by instantaneously and disappear.  Only the text remains.  As it
> happens, I am used to adding defaulted parameters in the macro call,
> and would like to know the explanation of the different results.
> 

Hi,

the commands enclosed in { } are executed as you would have written
them interactively, when the macro is finished, you can further use
the allocated objects. When you change the macro into a function,
normal scoping rules come into play and objects allocated on the
stack get destructed on exit.

TFile example and its objects get out of scope in your function.
Objects allocated on heap (there are copies of the histogram hpx drawn
by DrawCopy in the upper pads) do not.

        Jiri



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:25 MET