Created
July 2, 2010 23:16
-
-
Save r2p2/462061 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ main2.cpp -std=gnu++0x | |
#include <vector> | |
#include <memory> // shared_ptr | |
template <class T> | |
class Base | |
{ | |
public: | |
Base(T value) | |
:m_value(value) | |
{} | |
T value() | |
{ | |
return m_value; | |
} | |
void value(T new_value) | |
{ | |
m_value = new_value; | |
} | |
protected: | |
T m_value; | |
}; | |
class Integer : public Base<int> | |
{ | |
Integer(int new_value) | |
:Base<int>(new_value) | |
{} | |
}; | |
class Wrapper | |
{ | |
Wrapper(std::shared_ptr<Base<auto>> bptr) | |
:m_bptr(bptr) | |
{} | |
std::shared_ptr<Base<auto>> get() | |
{ | |
return m_bptr; | |
} | |
private: | |
std::shared_ptr<Base<auto>> m_bptr; | |
}; | |
int main() { | |
std::vector<Wrapper> list; | |
return list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment