Created
January 5, 2018 03:09
-
-
Save dongbum/aa9addc1aa651de66e51888f73dbe972 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
#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