Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: How to assign an object to another in it method? Date: Tue, 11 Jul 2017 17:56:00 -0000 (UTC) Organization: A noiseless patient Spider Lines: 20 Message-ID: References: <46334961-cc18-491f-828c-32e7401c7832@googlegroups.com> Reply-To: avl@logic.at Injection-Date: Tue, 11 Jul 2017 17:56:00 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="d629a330820a3f68460312d0178bfc23"; logging-data="22743"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Jgkca84L5c3RZtGLnTywM" User-Agent: slrn/1.0.2 (Linux) Cancel-Lock: sha1:6oZSoio9ITdpLZx1sWwQJHwJyas= Xref: csiph.com comp.lang.java.programmer:36847 Jerry Stuckle wrote: > Default values in a derived class which are not valid for the base class > indicates an invalid relationship in the first place. That's correct, but not relevant. It's not about whether one of the class's default would be "valid" for the other, but instead, that the subclass's default value might just be a better fit than the superclass's one, and that shouldn't depend on the compile-time type of the reference (or pointer)... In the example of employee and manager, the manager might just have a different "default" wage: Manager *mgr = new Manager(); mgr->setWage( /* uses Manager's default wage */ ); Employee *emp = mgr; emp->setWage( /* uses Employee's default wage */ );