Skip to content

Instantly share code, notes, and snippets.

@plonk
Last active December 19, 2015 16:19
Show Gist options
  • Select an option

  • Save plonk/5983259 to your computer and use it in GitHub Desktop.

Select an option

Save plonk/5983259 to your computer and use it in GitHub Desktop.
snippet from Design Patterns (pp.71-72)
void SpellingChecker::Check (Glyph* glyph) {
Character* c;
Row* r;
Image* i;
if (c = dynamic_cast<Character*>(glyph)) {
// analyze the character
} else if (r = dynamic_cast<Row*>(glyph)) {
// prepare to analyze r's children
} else if (i = dynamic_cast<Image*>(glyph)) {
// do nothing
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment