Article View: comp.os.ms-windows.programmer.misc
Article #2410(Borland?) C++ Language Question
From: J.C. Ashworth
Date: Thu, 28 Jan 1993 17:18
Date: Thu, 28 Jan 1993 17:18
47 lines
1608 bytes
1608 bytes
I dunno whether this relates solely to the Borland C++ compiler or whether
it's a general C++ feature / bug?
I seem to be able to do the following quite legally and with the expected
result:
class B
{
// ...
};
class C
{
// ...
};
class D : public B
{
int xtraField;
// ...
};
B& foo( ... );
D::func( ... )
{
D& temp = (D&) foo( ... );
temp.xtraField = 5;
}
Is this OK? How does the cast from B& to D& work? I suppose a cast from B& to C&
would NOT be legal?
thanks.
--
______________ _____________
/ /\ / /\ Julian Ashworth
/_____ ____/ / / _____ / / Magdalene College
\___/ /\ __\/ / /\___/ / / Cambridge
/ / / / /_/__/ / / England
/ / / / / /
__ / / / / _____ / / jca17@phx.cam.ac.uk
/ \_____/ / / / /\___/ / /
\ / / / / / / / /
\_________/ / /___/ / /___/ / "It's a great way to steal a car
\________\/ \___\/ \___\/ but where do we get a jet-pac?"
Technical Details
Message-ID:
<1993Jan28.171855.10953@infodev.cam.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!inmos!fulcrum!bham!warwick!pavo.csi.cam.ac.uk!jca17Show Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.misc Path: arc1-ca.pugleaf.net!sparky!uunet!inmos!fulcrum!bham!warwick!pavo.csi.cam.ac.uk!jca17 From: jca17@phx.cam.ac.uk (J.C. Ashworth) Subject: (Borland?) C++ Language Question Message-ID: <1993Jan28.171855.10953@infodev.cam.ac.uk> Sender: jca17@cl.cam.ac.uk (J.C. Ashworth) Nntp-Posting-Host: farcet.cl.cam.ac.uk Organization: U of Cambridge Computer Lab, UK Date: Thu, 28 Jan 1993 17:18:55 GMT Lines: 47