Last active
August 17, 2018 08:50
-
-
Save Noobgam/64ac15d1af52321b043deba97ea4688e 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
//a.cpp | |
//a.* can not include b.* | |
struct Test { | |
int Bar(); | |
}; | |
struct Test2 { | |
int Barr(); | |
}; | |
template <class T> | |
int Foo(T& t) { | |
return -1; | |
}; | |
template <> | |
int Foo<Test>(Test& t) { | |
return t.Bar(); | |
} | |
template <> | |
int Foo<Test2>(Test2& t) { | |
return t.Barr(); | |
} | |
//b.cpp | |
#include "a.cpp" | |
#include <iostream> | |
using namespace std; | |
struct Test { | |
int Bar() { return 1; } | |
}; | |
struct Test2 { | |
int Barr() { return 2; } | |
}; | |
int main() { | |
Test a; | |
Test2 b; | |
cout << Foo(a) << " " << Foo(b) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment