From -6149789955051561571
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fc1538f2aa3fc9f8
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1993-01-19 08:27:19 PST
Newsgroups: comp.std.c++
Path: sparky!uunet!uunet.ca!frumious!pat
From: pat@frumious.uucp (Patrick Smith)
Subject: Re: Type System
Message-ID: <C13CDK.n3@frumious.uucp>
Date: Tue, 19 Jan 1993 07:48:56 GMT
Reply-To: uunet.ca!frumious!pat
References: <1993Jan12.214547.20528@microsoft.com> <C0ux4A.C9@frumious.uucp> <1993Jan18.160334.17071@ucc.su.OZ.AU>
Organization: None
Lines: 42

maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
|In article <C0ux4A.C9@frumious.uucp> uunet.ca!frumious!pat writes:
|>   class A { public: A(); /* no const constructor */ };
|>   class B : pubic A { public: B() const; };
|>   B::B() const {}   // Error: uses non-const A::A()
|>                     // There is _no_ legal way to
|>                     // implement B::B() const!
|
|	So what? Make all the ctors 'const'.

In the example above, I was assuming one wasn't able to modify
the base class A.  So you're stuck with it not having a const
constructor.


|	This is really the problem: sometimes it isnt possible.
|(Example still required: anyone?)

I'm not sure, but I suspect that if one is allowed to modify
the base and member classes, then it is always possible
(barring unusual constraints posed by the application).
It might occasionally be quite awkward, though.

But if you can't modify the base and member classes, then it's
easy to construct examples where it's impossible.  For example,
a base class might not have a const constructor, as above.
Or a constructor may need to put a member into a state which
can only be achieved by calling non-const member functions for
the member object.


|	We could just decide all existing constructors
|we 'const' anyhow. That would fix the loophole without 
|changing anything.

I don't understand this.  Could you explain this in more detail?
(Maybe in e-mail if I'm missing something obvious.)

-- 
Patrick Smith
uunet.ca!frumious!pat
pat%frumious.uucp@uunet.ca


