Hi Masaharu, I admit that this clause is very vague. But almost anything in ANSI seems only vaguely related to the actual language. All the compilers I know, on OSF, Sun, and Linux, allow you to do this, using the copy constructor to create the array elements from the comma-separated initial values. This is simply a natural extension of what C allows you to do with its built-in types (see, for example, Kernighan & Ritchie). Such extensions are very common on C++. If it could be implemented in CINT, it will be a great advantage, both since it saves coding, and since users used to doing it in other compilers expect it to work here. Thanks, Abi > -----Original Message----- > From: Masaharu Goto [mailto:MXJ02154@nifty.ne.jp] > Sent: Monday, June 18, 2001 4:48 AM > To: Soffer, Abner > Cc: roottalk@pcroot.cern.ch > Subject: Array initialization > > > Hello Abi, > > Thank you for your report. Indeed, Cint is prohibiting this kind of > initialization. In fact, behavior to this kind of > initialization differs > from compiler to compiler. Some compilers do not allow this, > if I remember > correctly. It depends on how you interpret following clause > in ANSI/ISO C++. > > > 8.5.1 Aggregates [dcl.init.aggr] > > 1 An aggregate is an array or a class (clause _class_) with > no user- > declared constructors (_class.ctor_), no private or > protected non- > static data members (clause _class.access_), no base > classes (clause > _class.derived_), and no virtual functions (_class.virtual_). > > > In theory, it is possible. If this is important, please let me know. > > Thank you > Masaharu Goto > > > >CINT doesn't allow you to initialize array elements if they are of a > >user-defined > >type. For example: > > > >root [2] TString yes("yes"); > >root [3] TString t[2] = {yes, yes}} > >!!!Bad command input. Ignored!!! > >root [4] TString t[2] = {yes, yes} > >Error: Illegal initialization of t[2]. Constructor exists > >FILE:/tmp/fileBu9dJL_cint LINE:1 > >*** Interpreter error recovered *** > > > >This works if the code is manually compiled, or if I use a > double instead of > >TString. >
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:49 MET