Xref: utzoo comp.lang.c++:12846 comp.std.c++:826 comp.object:3154 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!linac!att!att!andante!alice!ark From: ark@alice.att.com (Andrew Koenig) Newsgroups: comp.lang.c++,comp.std.c++,comp.object Subject: Re: C++ possible new construct proposal Message-ID: <20203@alice.att.com> Date: 12 Apr 91 13:15:29 GMT References: <1991Apr11.155803.5410@mnemosyne.cs.du.edu> Reply-To: ark@alice.UUCP () Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 90 In article <1991Apr11.155803.5410@mnemosyne.cs.du.edu> cag@mnemosyne.cs.du.edu (Chris Gantz) writes: > class X { > type: > private: > // internal data representation for type; > int no_instantiations; > protected: > // protected interface for type; > public: > int instantaitions() { > return instantiations; > } > void update_instantiations() { > no_instantitations++; > } > object: > private: > // internal data representation for objects; > protected: > // protected interface for objects; > public: > X() { // default constructor > update_instantiations() > // object appropriate internal data initialization. > } > ~X() { } > void f() { } > }; > main() > { > X x_obj; > > x_obj.f(); // using x_obj through the object public interface > // below is an example of using the type X as an object... > no_current_instantiations = X.instantiations(); > } The first thing that comes to mind is to wonder what your proposal would do that static members can't? The following works right now: class X { private: // internal data representation for type; static int no_instantiations; public: static int instantiations() { return no_instantiations; } static void increase_instantiations() { no_instantiations++; } static void reduce_instantiations() { no_instantiations--; } private: // internal data representation for objects; protected: // protected interface for objects; public: X() { // default constructor increase_instantiations(); // object appropriate internal data initialization. } ~X() { reduce_instantiations(); } void f() { } }; int X::no_instantiations = 0; main() { X x_obj; x_obj.f(); // using x_obj through the object public interface // below is an example of using the type X as an object... int no_current_instantiations = X::instantiations(); } So the question is: what would your proposal do that cannot already be done just as easily? -- --Andrew Koenig ark@europa.att.com