Xref: utzoo comp.lang.c++:13069 comp.sys.mac.programmer:23984 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!lotus!lotus.com!robertk From: robertk@lotatg.lotus.com (Robert Krajewski) Newsgroups: comp.lang.c++,comp.sys.mac.programmer Subject: Pointers to sibling classes in conditional expressions Message-ID: Date: 25 Apr 91 15:00:48 GMT Sender: news@lotus.com Distribution: comp Organization: /homes/robertk/.organization Lines: 31 I have a function that returns a pointer to a parent class -- it looks at its arguments, and then makes a new object (with new) either of child class A, or B, depending on the arguments to this function. The decision is made in a conditional expression, and the result is returned: Parent * MakeIt(...) { ... return ( ? new A(...) : new B(...) ); } g++ warns that the two expressions are of different types, and so does MPW C++. However, it seems to me that I shouldn't get a warning. (MPW C++ actually considers this an error.) Return value conversion ought to be following the same rules as conversion of class pointer types. This code should not produce warnings: F(Parent * thing); F(new A(...)); F(new B(...)); ... and I would argue that something analogous is happening in the conditional expression example above. Is there anything in the ARM to contradict what I'm saying ? If so, do I have a reasonable complaint that should be addressed in the standards effort ?