Skip to content

Instantly share code, notes, and snippets.

@dongbum
Created January 5, 2018 03:09
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 dongbum/aa9addc1aa651de66e51888f73dbe972 to your computer and use it in GitHub Desktop.
Save dongbum/aa9addc1aa651de66e51888f73dbe972 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <memory>
template<typename T>
class A
{
public:
A(void) {};
static std::shared_ptr<A<T>> server_instance_;
static void SetServerInstance(std::shared_ptr<A<T>>& server_instance) { server_instance_ = server_instance; }
static std::shared_ptr<A<T>>& GetServerInstnace(void) { return server_instance_; }
};
class B
{
public:
B(void) {};
};
class C : public A<B>
{
public:
C(void) {};
};
int main()
{
//std::shared_ptr<C> aaa(new C); // 이렇게하면 밑에 줄에서 에러
std::shared_ptr<A<B>> aaa(new C);
C::SetServerInstance(aaa); // LNK2001 링크 에러...?
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment