Path: utzoo!utgpu!watmath!att!rutgers!ucsd!usc!cs.utexas.edu!uunet!dlogics!dsa From: dsa@dlogics.UUCP (David Angulo) Newsgroups: comp.lang.c++ Subject: inheriting casts and assignments Message-ID: <246@dlogics.UUCP> Date: 16 Nov 89 22:54:57 GMT Organization: Datalogics Inc., Chicago Lines: 45 // I have a question. When I compile the following code in Glockenspiel's // c++ v 1.2 E on the VAX under VMS 5.2: #include class a { int pdq; public: a () {pdq = 1;} void operator=(const a& source_a) {pdq=source_a.pdq+1;} int operator int() {return pdq;} }; class b : public a { public: b() : () {} }; main () { b a_b; a an_a; a_b = an_a; int c = (int)a_b; } // I get the following error messages: // designer C Preprocessor, release 1.2 E // AT&T C++ Compiler, release 1.2 E // Copyright 1984 AT&T Inc. and 1986 through 1988 Glockenspiel Ltd. //"sys$library:stddef.h", line 12: warning: " volatile" not implemented (ignored) //"q3.cxx", line 26: error: assignment not defined for class b //"q3.cxx", line 27: error: cannot cast class object to int // // I don't understand any of these error messages - shouldn't these methods // have been inherited from class a? -- David S. Angulo (312) 266-3134 Datalogics Internet: dsa@dlogics.UUCP 441 W. Huron UUCP: ..!uunet!dlogics!dsa Chicago, Il. 60610 FAX: (312) 266-4473