#include <iostream>
#include <vector>
int main()
{
class Int {
public:
Int(int _i) : i(i) {}
private:
int i;
};
std::vector<Int> VI;
}
मैं ऊपर कोड को संकलित करने के लिए प्रयास करें और मिल गया निम्न त्रुटि संदेश:क्यों एक स्थानीय प्रकार वेक्टर बनाने करता असफल
foo.cc: In function 'int main()':
foo.cc:13: error: 'main()::Int' uses local type 'main()::Int'
foo.cc:13: error: trying to instantiate 'template<class _Alloc> class std::allocator'
foo.cc:13: error: template argument 2 is invalid
foo.cc:13: error: invalid type in declaration before ';' token
आप में से किसी को भी मुझे बता सकते हैं क्यों मैं इस तरह बातें नहीं कर सकते हैं सी ++ में? अग्रिम में धन्यवाद।
एक ही प्रश्न नहीं, लेकिन एक ही मुद्दे पर एक और सवाल: [स्थानीय वर्गों का उपयोग एसएलएल एल्गोरिदम के साथ] (http://stackoverflow.com/questions/742607/using-local-classes-with-stl-algorithms) –