यह कोड गलत आउटपुट क्यों उत्पन्न करता है?टेम्प्लेट फ़ंक्शन is_same टेम्पलेट कक्षाओं में
//this-type.cpp
#include <iostream>
#include <type_traits>
using namespace std;
template<typename testype>
class A
{
public:
A()
{
cout << boolalpha;
cout << is_same<decltype(*this), A<int>>::value << endl;
}
};
class B : public A<int>
{
};
int main()
{
B b;
}
आउटपुट:
$ g++ -std=c++11 this-type.cpp
$ ./a.out
false
के प्रकार के "* इस" अंदर बी के माध्यम से एक एक < पूर्णांक> है, है ना?
, 'यह' की पूरी प्रकार क्या है, ' और * यह'? –
हालांकि निश्चित रूप से स्पष्ट नहीं है। –
अंतिम पंक्ति मेरे लिए काम नहीं करती है। मेरा आउटपुट 'झूठा', 'सत्य', 'झूठा' (जी ++ (उबंटू/लिनारो 4.7.2-2ubuntu1) 4.7.2) –