home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13350 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.2 KB  |  46 lines

  1. Path: sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!po.CWRU.Edu!esw
  2. From: esw@po.CWRU.Edu (Eric S. Wallace)
  3. Newsgroups: comp.lang.c++
  4. Subject: virtual destructor warning
  5. Date: 6 Sep 1992 18:09:14 GMT
  6. Organization: Case Western Reserve University, Cleveland, Ohio (USA)
  7. Lines: 35
  8. Message-ID: <18dhgaINN4r7@usenet.INS.CWRU.Edu>
  9. NNTP-Posting-Host: thor.ins.cwru.edu
  10.  
  11.  
  12. I have some classes in the following relationship:
  13.  
  14. class ibuf {
  15. public:
  16.   ibuf(int);
  17.   ~ibuf(void) { /* ... */ }
  18. };
  19.  
  20. class obuf {
  21. public:
  22.   obuf(int);
  23.   ~obuf(void) { /* ... */ }
  24. };
  25.  
  26. class iobuf : public obuf, public ibuf {
  27. public:
  28.   iobuf(int, int);
  29. };
  30.  
  31. When compiling with gcc-2.2.2, I get the following warning:
  32.  
  33.   destructor `ibuf::~ibuf()' non-virtual in relationship `iobuf: ibuf'
  34.  
  35. The warning occurs for whatever class is listed last in the list of base
  36. classes for iobuf. It was my understanding that if a derived class had no
  37. explicit destructor, a default one would be created that destructed each
  38. base class in the reverse order they appear in the list. Is this not the
  39. case? Why would ibuf::~ibuf have to be virtual?
  40.  
  41. Thanks in advance,
  42.  
  43. Eric Wallace
  44. wallace@chezmoto.ai.mit.edu
  45. esw@po.cwru.edu
  46.