Path: utzoo!attcan!uunet!jarthur!usc!cs.utexas.edu!milano!cadillac!dsouza From: dsouza@optima.cad.mcc.com (Desmond Dsouza) Newsgroups: comp.lang.c++ Subject: Re: virtual static class functions Message-ID: Date: 15 Mar 90 17:03:50 GMT References: <38579@cornell.UUCP> <2380@dataio.Data-IO.COM> Sender: news@cadillac.CAD.MCC.COM Organization: MCC CAD Program, Austin, Texas Lines: 46 In-reply-to: bright@Data-IO.COM's message of 14 Mar 90 21:06:37 GMT In article <38579@cornell.UUCP> deb@svax.cs.cornell.edu (David Baraff) writes: static_func(); Clearly, static_func() cannot access any non_static data or function members of Class because of case (a). 2. The above restriction does NOT rule out permitting static_func() to be VIRTUAL. If the invocation is as in (a) above, the call is resolved statically, like any other member function call -- virtual or non-virtual. If the invocation is as in (b) above, the call gets resolved dynamically through the virtual function table. Only VIRTUAL static member functions need be entered in this table. Whether or not am *implmentation* chooses to pass an implicit "this" pointer as a first argument to VIRTUAL static member functions is unimportant and may be decided by implementation convenience : the function cannot use any non-static members anyway so the value of "this" is irrelevant. In summary, VIRTUAL static member functions are entered in the virtual function table, may only access static data and functions, and may or may not be actually passed a "this" pointer. Non-virtual static member functions would remain unchanged. It is easy to come up with examples where this is useful. Desmond. -- ------------------------------------------------------------------------------- Desmond D'Souza, MCC CAD Program | ARPA: dsouza@mcc.com | Phone: [512] 338-3324 Box 200195, Austin, TX 78720 | UUCP: {uunet,harvard,gatech,pyramid}!cs.utexas.edu!milano!cadillac!dsouza