home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19829 < prev    next >
Encoding:
Text File  |  1993-01-24  |  1.2 KB  |  34 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Virtual function call within constructors
  5. Message-ID: <1993Jan24.164709.18400@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <1993Jan24.051330.3721@dcc.uchile.cl>
  8. Date: Sun, 24 Jan 1993 16:47:09 GMT
  9. Lines: 23
  10.  
  11. gschwarz@dcc.uchile.cl (Guillermo Schwarz Utrup) writes:
  12.  
  13. To: gschwarz@dcc.uchile.cl
  14. Subject: Re: Virtual function call within constructors
  15. Newsgroups: comp.lang.c++
  16. References: <1993Jan24.051330.3721@dcc.uchile.cl>
  17.  
  18. In comp.lang.c++ you write:
  19.  
  20. >I have found that virtual functions are not handled as one could expect
  21. >when called from a constructor.
  22.  
  23. That is because you are not expecting the right thing.  Look up
  24. virtual functions in constructors in any good C++ text.
  25.  
  26. When constructing a base class, only functions visible from that class
  27. constructor can be called.  The derived class has not been constructed yet,
  28. so you can't call any of its functions.  For example, the derived version
  29. of the virtual function might depend on data set up by the derived
  30. constructor, which won't have yet been called.
  31. -- 
  32.  
  33. Steve Clamage, TauMetric Corp, steve@taumet.com
  34.