Path: utzoo!attcan!uunet!snorkelwacker!apple!netcom!sjsumcs!horstman From: horstman@sjsumcs.sjsu.edu (Cay Horstmann) Newsgroups: comp.lang.c++ Subject: Re: Class member initialization proposal Message-ID: <1990Apr13.064548.1133@sjsumcs.sjsu.edu> Date: 13 Apr 90 06:45:48 GMT References: <14560@cit-vax.Caltech.Edu> Reply-To: horstman@sjsumcs.SJSU.EDU (Cay Horstmann) Organization: San Jose State University Lines: 35 In article <14560@cit-vax.Caltech.Edu> ronen@cit-vax.Caltech.Edu (Ronen Barzel) writes: >WHAT DO I WANT? > >An extra capability in C++: the ability to specify initializations >for class members within the class definition, as part of the member >declaration. Thus, for example, I would like the following to be legal: > > > OLD NEW > ---------------------- ------------------------------ > class A { class A { > char *ptr; char *ptr = 0; > const int n; const int n = 3; ... > A(); A(); > A(int); A(int); > }; }; ... I don't think this is so great. The only benefit would be to give the compiler a hint to factor out code common to all constructors. But you could do that manually with a member function. HOWEVER, for static const this would indeed be very desirable: class Table { static const int SIZE = 20; Whatnot* t[ SIZE ]; // ... }; Whatever you do, please do not post back that I could use a local enum { SIZE = 20 }. Cay