Thread View: comp.os.ms-windows.programmer.misc
1 messages
1 total messages
Started by J.C. Ashworth
Thu, 28 Jan 1993 17:18
(Borland?) C++ Language Question
Author: 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?"
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads