c++ - Alternative to RTTI for Comparing Subclasses -


i have think should simple design i'm having trouble coming solution doesn't involve rtti (or methods return type). have generic shape interface contains pure virtual draw method only. elsewhere in program, have vector of pointers shapes, , invoke draw call on each shape.

now, extend functionality of shape allow shapes compare 1 , return whether or not overlap. obviously, code depends on specific type of subclass of shape -- is, code determine whether 2 circles overlap different code determine whether circle , rectangle overlap. right now, using typeid followed dynamic cast dispatch 2 objects correct overlap code, seems kludgy. there pattern or technique can use avoid use of typeid , static_casts?


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -