[ROOT] conditional object declaration

From: K.-Michael Aye (klaus-michael.aye@durham.ac.uk)
Date: Wed May 21 2003 - 12:35:54 MEST


Hi all,

I tried something like this


#includes...

Int_t Macro(Int_t Dimension)
{
   if (Dimension ==2) TH2F* histo = new TH2F("histo"...)
   else if (Dimension ==3) TH3F* histo = new TH3F("histo"...)


But later in the code I want to fill histo

  if (Dimension == 2) histo->Fill(...)
  else if (Dimension == 3) histo->Fill(..)

But during compilation with Aclic, it complains at fill-time that histo is 
undeclared. So is conditional declaration not allowed then? Or how could I 
achieve what I want to do?

Greetings,
Michael

PS.: root 3.05/03, gcc 3.2 under Linux
-- 
K.-Michael Aye, University of Durham, Dept. of Physics
Phone@Work: +44-191-374-2345, Fax@Work: +44-191-374-3749
"Because the exploration of space knows no national boundaries,
the loss of the Columbia is a loss to all humankind!"(Kofi Annan)



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET