Article View: net.lang.c++
Article #76Is this a C++ bug?
From: keith
Date: Fri, 07 Mar 1986 20:11
Date: Fri, 07 Mar 1986 20:11
29 lines
1120 bytes
1120 bytes
A member of a const argument cannot be used as a const argument in a
function call:
class Foo { int i; };
class Bar {
Foo foo;
public:
void g(const Foo&);
void f(const Bar& b) { g(b.foo); } // gets error
};
"constbug.c", line 7: error: address of member Bar::foo of const Bar
Is this a bug in C++ Release 1.0 or a "feature"?
Incidentally, you can get around this with an explicit cast:
{ g(((Bar*)&b)->foo); }
--
---
Keith Gorlen
Computer Systems Laboratory
Division of Computer Research and Technology
National Institutes of Health
Bethesda, MD 20892
phone: (301) 496-5363
uucp: {decvax!}seismo!elsie!cecil!keith
Technical Details
Message-ID:
<58@cecil.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!gatech!seismo!elsie!cecil!keithShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!gatech!seismo!elsie!cecil!keith From: keith@cecil.UUCP Newsgroups: net.lang.c++ Subject: Is this a C++ bug? Message-ID: <58@cecil.UUCP> Date: Fri, 7-Mar-86 15:11:24 EST Article-I.D.: cecil.58 Posted: Fri Mar 7 15:11:24 1986 Date-Received: Sun, 9-Mar-86 08:46:16 EST Organization: NIH-CSL, Bethesda, MD Lines: 29