Skip to content

Instantly share code, notes, and snippets.

@fpersson
Created November 4, 2011 23:23
Show Gist options
  • Save fpersson/1340761 to your computer and use it in GitHub Desktop.
Save fpersson/1340761 to your computer and use it in GitHub Desktop.
Simple interface demo
#include <iostream>
#include <vector>
class IShape{
public:
virtual void print() = 0;
private:
};
class Rect : public IShape{
public:
void print(){
std::cout << "Rect" << std::endl;
}
};
class Circle : public IShape{
public:
void print(){
std::cout << "Circle" << std::endl;
}
};
int main(int argc, char **argv) {
std::vector<IShape*> shapes;
shapes.push_back(new Circle());
shapes.push_back(new Rect());
shapes[0]->print();
shapes[1]->print();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment