home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19586 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  1.9 KB

  1. Xref: sparky comp.lang.c:19586 comp.lang.c++:19015
  2. Newsgroups: comp.lang.c,comp.lang.c++
  3. Path: sparky!uunet!taumet!steve
  4. From: steve@taumet.com (Steve Clamage)
  5. Subject: Re: C/C++ Speed
  6. Message-ID: <1993Jan12.164147.18840@taumet.com>
  7. Organization: TauMetric Corporation
  8. References: <1ipsk5INNf5m@aludra.usc.edu> <dak.726696239@tabaqui> <1993Jan11.163852.19740@informix.com>
  9. Distribution: usa
  10. Date: Tue, 12 Jan 1993 16:41:47 GMT
  11. Lines: 31
  12.  
  13. cshaver@informix.com (Craig Shaver) writes:
  14.  
  15. >Who implements an intelligent C++ linker???  I was under the impression that 
  16. >you get all the functionality in a class when you link, whether you use it 
  17. >or not.  
  18.  
  19. Most C++ implementations use a linker which works like the linker for C;
  20. often it is the same linker.  With typical implementations, a function
  21. is included in the executable if it is referenced (called or address
  22. taken), or if it is in the same module as something else which is referenced.
  23.  
  24. If the C++ programmer puts all the class functions in one module, then
  25. any use of the class gets the code for all functions, but not necessarily
  26. otherwise.  Class member functions may be divided up among different
  27. source modules just like ordinary functions.
  28.  
  29. That is the situation in C++ for non-class functions, and for class member
  30. functions which are not "virtual".
  31.  
  32. If a class has "virtual functions", their addresses are usually kept in
  33. a table which becomes part of the executable.  This means that all the
  34. virtual functions are referenced by this table, and thus included in
  35. the program whether or not they are called.  The C++ language does not
  36. require this implementation of virtual functions, but it is the usual case.
  37.  
  38. The situation is comparable to a C programmer making a table of
  39. functions or a switch statement which might call any of several functions.
  40. The functions get linked into the program whether or not they are called.
  41. -- 
  42.  
  43. Steve Clamage, TauMetric Corp, steve@taumet.com
  44.