मैं बहुत की तरह एक cpp में एक विशेष समारोह को परिभाषित कर सकते हैं ...सीपीपी में टेम्पलेट विशेषज्ञता परिभाषित करें?
// हैडर
template<typename T>
void func(T){}
template<>
void func<int>(int);
// सीपीपी
template<>
void func<int>(int)
{}
मैं कैसे एक विशेष वर्ग में एक विधि को परिभाषित कर सकते एक सीपीपी में? इसलिए जैसा (जो काम नहीं करता, मैं error C2910: 'A<int>::func' : cannot be explicitly specialized
प्राप्त) ...
// हैडर
template<typename T>
struct A
{
static void func(T){}
};
template<>
struct A<int>
{
static void func(int);
};
// सीपीपी
template<>
void A<int>::func(int)
{}
आप की जाँच क्या इस: http://stackoverflow.com/questions/115703/storing-c-template-function-definitions-in-a-cpp-file – Reunanen
@Pukku कि में एक विधि की चिंताओं विशेषज्ञता एक गैर-टेम्पलेटेड वर्ग, जो वास्तव में एक स्टैंडअलोन फ़ंक्शन की विशेषज्ञता के समान है (जैसा ऊपर मेरे कामकाजी उदाहरण में है)। मैं एक सीपीपी में एक विशेष _class_ में एक विधि को परिभाषित करने के बारे में पूछ रहा हूँ। – David