संभावित डुप्लिकेट एक टेम्पलेट निर्दिष्ट इनपुट प्रकार के साथ एक और टेम्पलेट वर्ग इनहेरिट:
GCC problem : using a member of a base class that depends on a template argument
Why does GCC need extra declarations in templates when VS does not?
Why doesn’t a derived template class have access to a base template class
iphone compiler inherited templated base classes with passed through type not being expanded in time (just look)सी ++ खाका वर्ग
भ्रामक शीर्षक के लिए क्षमा करें, सबसे अच्छा मैं साथ आ सकता था।
यहाँ मेरी समस्या को वर्णन करने के लिए कुछ कोड है ...
एक आधार टेम्पलेट वर्ग:
template<class T> class TestBase
{
public:
int someInt;
};
अन्य टेम्पलेट वर्ग के साथ TestBase उपवर्ग करने का प्रयास कर ...
यह संकलन समय पर "कुछ इस दायरे में घोषित नहीं किया गया" प्राप्त होता है:
template<class X> class TestSub : public TestBase<X>
{
void testf()
{
someInt = 0; //Error: "someInt was not declared in this scope"
}
};
बी) यह (अंतर किया जा रहा है कि मैं TestBase के टेम्पलेट इनपुट स्पष्ट रूप से)
template<class X> class TestSub : public TestBase<string>
{
void testf()
{
someInt = 0;
}
};
TestSub (ए से क्यों निर्दिष्ट ठीक काम करता है) के वारिस नहीं कुछ ठीक से नहीं है क्योंकि यह (बी) में करता है?
अग्रिम धन्यवाद।
http://stackoverflow.com/questions/11405/gcc-problem-using-a-member-of-a-base-class-that-depends-on-a-template-argument की डुप्ली के रूप में बंद किया गया है और http://stackoverflow.com/questions/1643035/typedef-in-template-base-class और http://stackoverflow.com/questions/1239908/why-doesnt-a-derived-template-class-have-access- टू-ए-बेस-टेम्पलेट-क्लास और http://stackoverflow.com/questions/2812470/why-does-gcc-need-extra-declarations-in-templates-when-vs-does-not और कई अन्य –