🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #252

Re: Declarations of Member Functions Outside Class Definitions

#252
From: hopper
Date: Thu, 02 Aug 1990 23:46
47 lines
2815 bytes
In article <65729@lll-winken.LLNL.GOV> howell@bert.llnl.gov (Louis Howell) writes:
>In article <46393@brunix.UUCP>, sdm@cs.brown.edu (Scott Meyers) writes:
>|>Proposed:
>|>
>|>  That it be possible to declare member functions outside of class
>|>  declarations exclusively for the purpose of later friend declarations.
>|>
>|>Example:
>|>
>|>  class Example;                      // currently legal
>|>  void Example::f(int);               // currently illegal, but would be ok
>|>
>|>  class Sample {
>|>    friend void Example::f(int);      // currently legal, provided class
>|>                                      // Example has been defined
>|> <stuff deleted here>
>|>  };
>
>Why should even this be necessary?  The friend declaration contains all
>of the information necessary to deduce the declarations of Example and
>Example::f(int), so why not omit these declarations too?

Stuff deleted.

	I'm not precisely certain of how this is implemented, but what if
you declared a virtual member function of a class, and then use the
mechanism proposed in this article to declare it to be a friend? If you
called this function, how would the compiler generate the code to select the
proper virtual function if it was unaware of the other parts of the class
declaration?

	As I understand it now, the compiler knows how many virtual
functions you have, so it just makes a reference to the proper member of an
array of function pointers. If the compiler didn't know how many virtual
functions had been declared, it would have to somehow pass this task on to
the linker. This would mean substantial changes to the linker and it's
ability to change references to symbols into hard addresses. At least I
think so.

Probably just being stupid,
UUCP: rutgers!umn-cs!ux.acs.umn.edu!hopper   (Eric Hopper)
     __                    /)                       /**********************/
    / ')                  //                         * I went insane to   *
   /  / ______  ____  o  //  __.  __  o ____. . _    * preserve my sanity *
  (__/ / / / <_/ / <_<__//__(_/|_/ (_<_(_) (_/_/_)_  * for later.         *
Internet:              />                            * -- Ford Prefect    *
hopper@ux.acs.umn.edu </  #include <disclaimer.h>   /**********************/
Technical Details
Message-ID: <1946@ux.acs.umn.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ames!rex!wuarchive!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!uc!cs.umn.edu!ux.acs!hopper
References: <46393@brunix.UUCP> <65729@lll-winken.LLNL.GOV>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ames!rex!wuarchive!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!uc!cs.umn.edu!ux.acs!hopper
From: hopper@ux.acs.umn.edu (hopper)
Newsgroups: comp.std.c++
Subject: Re: Declarations of Member Functions Outside Class Definitions
Message-ID: <1946@ux.acs.umn.edu>
Date: 2 Aug 90 23:46:21 GMT
References: <46393@brunix.UUCP> <65729@lll-winken.LLNL.GOV>
Reply-To: hopper@ux.acs.umn.edu (Eric Hopper)
Organization: Omnifarious Software
Lines: 47