Skip to content

Instantly share code, notes, and snippets.

@kobake
Created August 26, 2018 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobake/edda55f0c47094067acb715d99e0c9b7 to your computer and use it in GitHub Desktop.
Save kobake/edda55f0c47094067acb715d99e0c9b7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <vector>
class IDumpable {
public:
virtual void Dump() = 0;
};
// For inheritance
template <class T>
class Hoge : public IDumpable, public std::vector<T>{
public:
void Dump() {
printf("size = %d\n", this->size());
}
};
int main()
{
Hoge<int> a;
a.push_back(10);
a.push_back(20);
IDumpable* d = &a;
d->Dump();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment