Topic: Post-constructors and pre-destructor


Author: crayton@delphi.com (Chris Crayton)
Date: 3 Jan 1995 05:01:26 GMT
Raw View
>And why can't static member functions be const ???

A const member function relies on an instance of that class, while a static
member function exists *independantly* of any such class.  According to the
spec, a static member function exists even if instances of the class don't
exist yet.

>: this is an explicit restriction of C++, not a logical necessity.  Some
>: calls to static member functions do not specify a particular instance,
>: but others do.  There is no particular reason (except perhaps for ease
>: of implementation?) to disallow static virtual functions, which could
>: certainly exhibit virtual behaviour if called via a pointer or
>: reference.

Only if an instance of the class in which the static member function belongs
has an instance.  There is no way for the compiler to know at compile-time
if such an instance will actually exist at run-time.  Because of this, it s
easier to simply disallow the practice of a const static member function.


+--------------------+------------------------------------------------+
| crayton@delphi.com | I have come to chew bubble-gum and kick butt,  |
| Team OS/2          | and I'm all out of butt.  -- Crow T. Robot     |