Topic: const access, question.


Author: ldh@cs.brown.edu (Laurent Hasson)
Date: Mon, 7 Nov 1994 00:24:41 GMT
Raw View
I have an interesting problem which i am not sure what to think of:

class _A_
 { public:
      _A_() { i=0; }
     ~_A_() { }
   protected:
      int i;
   public:
     void Toto1() {  i++; }
 };

class _B_ : public _A_
 { public:
      _B_() { j=0; }
     ~_B_() { }
   protected:
      int j;
   public:
     void Toto2() {  j++; }
 };

void temp(const _B_* b)
 { b->Toto2(); // Compiler error, non const function on const object
   b->Toto1(); // Nothing, not a warning, nada.
 }


I am using SunsPro CC 3.0


Laurent.




Author: jason@cygnus.com (Jason Merrill)
Date: Mon, 7 Nov 1994 02:27:06 GMT
Raw View
Looks like a compiler bug; the second call should give you an error, too.

Jason