Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #80659
| Path | csiph.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx03.ams4.POSTED!not-for-mail |
|---|---|
| From | Mr Flibble <flibble@reddwarf.jmc> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: dynamic_cast |
| Message-ID | <20210703200658.00005201@reddwarf.jmc> (permalink) |
| References | <20210627225136.00005d66@reddwarf.jmc> <sbbr3u$a3j$1@dont-email.me> <sbl7mh$kb5$1@dont-email.me> <sbpm58$tfv$1@dont-email.me> <oMZDI.15364$SA.31@fx39.iad> <sbpq4k$ql6$1@dont-email.me> <j3_DI.7823$en4.873@fx34.iad> <sbpu3o$pkd$1@dont-email.me> <Uz%DI.3582$uM6.29@fx21.iad> <sbq1qu$kvs$1@dont-email.me> <Rz1EI.20284$_j1.1562@fx09.iad> |
| Organization | Jupiter Mining Corp |
| X-Newsreader | Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-w64-mingw32) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Lines | 26 |
| X-Complaints-To | abuse@eweka.nl |
| NNTP-Posting-Date | Sat, 03 Jul 2021 19:06:58 UTC |
| Date | Sat, 3 Jul 2021 20:06:58 +0100 |
| X-Received-Bytes | 1977 |
| Xref | csiph.com comp.lang.c++:80659 |
Show key headers only | View raw
On Sat, 3 Jul 2021 13:59:14 -0400 Richard Damon <Richard@Damon-Family.org> wrote: > On 7/3/21 12:04 PM, Bonita Montero wrote: > >> Wrong, the NUMBER of functions needed grows way to fast to be > >> scalable. > > > > Use an enum and return an enum-value in _one_ function. > > That's faster than a dynamical downcast. > > Doesn't handle the Animal -> Mammel -> Canine -> Dog -> Poodle case > without a big lookup table to say that Poodles are also Dogs and > Canines, and Mammels. > > You STILL need to edit the Animal.h file every time you add new > derived class. Lack of Encapsulation. You are both wrong; if you are using dynamic_casts or isDog() then that suggests you animal abstraction isn't elaborate enough, animal class should include a list of behaviours as child objects (i.e. composition instead of inheritance) and one such behaviour might be barking, canBark(), and could be used together with the visitor pattern, for example. /Flibble
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
dynamic_cast Mr Flibble <flibble@reddwarf.jmc> - 2021-06-27 22:51 +0100
Re: dynamic_cast Öö Tiib <ootiib@hot.ee> - 2021-06-27 15:01 -0700
Re: dynamic_cast Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-06-27 22:30 +0000
Re: dynamic_cast "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-06-27 16:35 -0700
Re: dynamic_cast Bonita Montero <Bonita.Montero@gmail.com> - 2021-06-28 08:44 +0200
Re: dynamic_cast Vir Campestris <vir.campestris@invalid.invalid> - 2021-07-01 21:14 +0100
Re: dynamic_cast Öö Tiib <ootiib@hot.ee> - 2021-07-01 14:16 -0700
Re: dynamic_cast red floyd <no.spam.here@its.invalid> - 2021-07-01 17:48 -0700
Re: dynamic_cast Bonita Montero <Bonita.Montero@gmail.com> - 2021-07-03 14:45 +0200
Re: dynamic_cast Richard Damon <Richard@Damon-Family.org> - 2021-07-03 09:39 -0400
Re: dynamic_cast Bonita Montero <Bonita.Montero@gmail.com> - 2021-07-03 15:53 +0200
Re: dynamic_cast Richard Damon <Richard@Damon-Family.org> - 2021-07-03 09:59 -0400
Re: dynamic_cast Bonita Montero <Bonita.Montero@gmail.com> - 2021-07-03 17:01 +0200
Re: dynamic_cast Richard Damon <Richard@Damon-Family.org> - 2021-07-03 11:42 -0400
Re: dynamic_cast Bonita Montero <Bonita.Montero@gmail.com> - 2021-07-03 18:04 +0200
Re: dynamic_cast Richard Damon <Richard@Damon-Family.org> - 2021-07-03 13:59 -0400
Re: dynamic_cast Mr Flibble <flibble@reddwarf.jmc> - 2021-07-03 20:06 +0100
Re: dynamic_cast Bonita Montero <Bonita.Montero@gmail.com> - 2021-07-04 07:06 +0200
Re: dynamic_cast Richard Damon <Richard@Damon-Family.org> - 2021-07-03 14:03 -0400
Re: dynamic_cast Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-08-07 13:06 -0700
csiph-web