home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18593 < prev    next >
Encoding:
Text File  |  1992-12-31  |  1.7 KB  |  67 lines

  1. Path: sparky!uunet!plsparc!surendra
  2. From: surendra@plsparc.UUCP (Surendra Goel)
  3. Newsgroups: comp.lang.c++
  4. Subject: possible bug in MSC7.0 ....
  5. Keywords: Multiple Inheritence, Virtual Base Class, MSC7.0
  6. Message-ID: <435@plsparc.UUCP>
  7. Date: 31 Dec 92 14:53:46 GMT
  8. Organization: Personal Library Software Inc., Rockville MD
  9. Lines: 56
  10.  
  11.  
  12. What is wrong with these classes? Is this a bug in  MSC 7.0 compiler?
  13. The problem is with "virtual base class". If I remove the
  14. "virtual" keyword from the abstract base class then it does not complain.
  15. Is anybody from Microsoft is aware of this problem?
  16.  
  17. See the error message generated by the compiler after the class listing.
  18.  
  19. ---------------------------- begins here -----------------------------------
  20.  
  21. class TestBase {
  22.       protected:
  23.         TestBasew();
  24.         virtual ~TestBase();
  25.     public:
  26.         virtual int test() = 0;
  27. };
  28. class TestBase1 : virtual public TestBase {
  29.       protected:
  30.         TestBase1();
  31.         virtual ~TestBase1();
  32.     public:
  33.         virtual int test() = 0;
  34.         virtual int test1() = 0;
  35. };
  36.  
  37. class TestBase2 : virtual public TestBase {
  38.       protected:
  39.         TestBase2();
  40.         virtual ~TestBase2();
  41.     public:
  42.         virtual int test() = 0;
  43.         virtual int test2() = 0;
  44. };
  45.  
  46. class TestDer : public TestBase1, public TestBase2 {
  47.   public:
  48.       TestDer() {};
  49.     ~TestDer() {;};
  50.     int test();
  51.     int test1();
  52.     int test2();
  53. };
  54. -------------------------------------- ends here ----------------------------
  55. cl /c test.cpp
  56.  
  57. test.cpp
  58. test.cpp(38) : error C2248: 'TestBase::~TestBase' : cannot access 'protected' member declared in class 'TestBase'
  59.  
  60.  
  61.  
  62. PS: I am not aware of any restriction on protected member in the derived
  63. class.
  64. -- 
  65. Surendra Goel (surendra@pls.com)
  66. Personal Library Software, Inc.  2400 Research Blvd. Suite 350, Rockville, MD 20850   Phone: (301)926-1402 
  67.