Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Thanks for the input on the bug in my code. Too bad my solution wouldn't work. Although your code does work, it seems like way too much effort and you having to know beforehand what the images are going to be. :( Perhaps completely giving up the polymorphism is the best approach in this specific case. Commented May 12, 2016 at 7:47
  • @DavidPacker I don't know if this is what I am looking for.....I posted my quick band aid solution that I came up with Commented May 12, 2016 at 12:51
  • If you don't want a switch/case, you can just declare an array of {char; Image} structs for each concrete font in sorted order, and search it. The search part is mechanical and can probably go in the base class. Commented May 12, 2016 at 16:50
  • @DarthRubik: The trick with UnionBase works best if the set of derived classes is stable and relatively small. The problem is that adding a derived class will cause a massive rebuild, because all places that depend on the Image interface will be affected. Commented May 12, 2016 at 19:01
  • @BartvanIngenSchenau I do every thing all headers anyways on my micro projects so that is not a huge deal Commented May 12, 2016 at 21:45