Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- template <class T>
- class Singleton {
- public:
- static T& GetInstance() {
- static T instance_;
- return instance_;
- }
- protected:
- Singleton() {}
- };
- class Foo : public Singleton<Foo> {
- public:
- std::vector<int> value;
- };
- int main() {
- Foo::GetInstance().value.push_back(1);
- std::cout << Foo::GetInstance().value.size() << "\n";
- std::cout << "Hello\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement