#include <iostream>
#include <memory>
template<typename T>
class Test: public std::enable_shared_from_this< Test<T> >
{
public:
std::shared_ptr< Test<T> > getMe()
{
return shared_from_this();
};
};
int main(int argc, const char * argv[])
{
Test<int> aTest;
return 0;
}
पर काम नहीं कर जब मैं मैंenable_shared_from_this xcode 5
Use of undeclared identifier 'shared_from_this'
मिल मैं इसे और विजुअल स्टूडियो 2010.
आप इसे 'std ::' जैसे 'std :: shared_from_this()' के साथ अर्हता प्राप्त करना भूल गए। –
यहां कोई भी std नेमस्पेस केवल enable_shared_from_this से विस्तार करने के लिए आवश्यक नहीं है और getMe फ़ंक्शन के रिटर्न प्रकार में और वे पहले ही टाइप किए गए हैं। –
प्लस shared_from_this enable_shared_from_this क्लास पर सदस्य फ़ंक्शन है। क्या आप वाकई सवाल पढ़ रहे हैं? –