home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16595 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.7 KB  |  52 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!ut-emx!jamshid
  2. From: jamshid@ut-emx.uucp (Jamshid Afshar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: base classes and typedef not working?
  5. Summary: it's a bug: BC++ doesn't allow typedef in member init. list
  6. Message-ID: <83992@ut-emx.uucp>
  7. Date: 19 Nov 92 21:41:32 GMT
  8. References: <1992Nov14.190608.28656@muddcs.claremont.edu>
  9. Reply-To: jamshid@emx.utexas.edu
  10. Organization: The University of Texas at Austin; Austin, Texas
  11. Lines: 39
  12.  
  13. In article <1992Nov14.190608.28656@muddcs.claremont.edu> dfoster@jarthur.claremont.edu (Derek R. Foster) writes:
  14. >In BC++ 3.1 the following code produces the error
  15. >"MatrixBase is not a base class of Matrix"
  16. >
  17. >typedef Array2<Scalar> MatrixBase;
  18. >
  19. >class Matrix : public MatrixBase
  20. >{
  21. >  Matrix(int row, int col) : MatrixBase(row,col) {}; // error occurs here
  22. >};
  23.  
  24. Actually, this bug shows up whether or not you're using templates
  25. (though there are other typedef bugs specific to templates).  A
  26. constructor's member initialization list appears to be the only place
  27. BC++ 3.1 has problems using a typedef instead of the actual class
  28. name.  I've already reported this to bugs@borland.com (no reply or
  29. tech. support).  Just put the actual class name in for now, maybe
  30. marking it with a comment so you can fix it later.  If you'd like a
  31. copy of my bug reports (mostly template related), just email me.
  32.  
  33.     class Base {
  34.     public:
  35.        virtual void f();
  36.     };
  37.  
  38.     typedef Base B;
  39.  
  40.     class Derived : public B {
  41.     public:
  42.        Derived()
  43.           : B() {}  // BC++ error, but legal code.  Use "Base()" for now.
  44.        virtual void f() {
  45.           B::f();   // okay, no complaints from BC++
  46.           //...
  47.           }
  48.     };
  49.  
  50. Jamshid Afshar
  51. jamshid@emx.utexas.edu
  52.