Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created January 30, 2014 15:53
Show Gist options
  • Save trikitrok/74cd4f76941dffa6700d to your computer and use it in GitHub Desktop.
Save trikitrok/74cd4f76941dffa6700d to your computer and use it in GitHub Desktop.
Duck class implementation
#include "Duck.h"
#include "QuackBehavior.h"
Duck::Duck(QuackBehavior * quackBehavior) {
howToQuack = quackBehavior;
}
Duck::~Duck() {
delete howToQuack;
}
void Duck::quack() {
howToQuack->quack();
}
void Duck::changeHowToQuack(QuackBehavior * quackBehavior) {
delete howToQuack;
howToQuack = quackBehavior;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment