Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!wuarchive!csus.edu!beach.csulb.edu!nic.csu.net!csun!csunb.csun.edu!abcscnge From: abcscnge@csunb.csun.edu (Scott Neugroschl) Newsgroups: comp.lang.c++ Subject: Inheritance and references question Summary: TC++ and G++ are different -- who's right? Message-ID: <1991Feb26.060459.6777@csun.edu> Date: 26 Feb 91 06:04:59 GMT Sender: news@csun.edu (News Administrator) Organization: csun Lines: 56 Hi. I have a question about inheritance and references. I have the following classes: class StackEntry { public: StackEntry() { } virtual ~StackEntry() { } }; class Stack { public: // ... Stack& operator>(StackEntry*&); // Stack pop operator // .... private: // ... }; class Disk : public StackEntry { // ... }; // ... Stack s; Disk *dp; // ... s > dp; // pop s into dp <<== PROBLEM HERE Now the question. Turbo C++ generates a temporary variable (implicit type cast) so that dp never gets set. G++, on the other hand allows the construct, and the code does what I expect. Since Disk is a subclass of StackEntry, and a Disk* can be assigned to a StackEntry*, I think G++ is right. Is it? If not, why? Please respond via Email, as I don't get on this system too often. Thanks, Scott Internet: abcscnge@csunb.csun.edu Compu$erve: 72027,3162 GEnie: S.NEUGROSCHL AT&T: (818)-902-4507 USnail: 8000 Woodley Ave M/S 44-55 Van Nuys, CA, 91409 -- Scott "The Pseudo-Hacker" Neugroschl abcscnge@csuna.csun.edu -- Beat me, Whip me, make me code in Ada -- Disclaimers? We don't need no stinking disclaimers!!!