जब एक साधारण वर्ग (g++ myclass.cpp
), मैं निम्नलिखित त्रुटि मिलती है संकलित करने के लिए कोशिश कर रहा है:आईएसओ सी ++ कोई प्रकार के साथ 'टपल' की घोषणा की मनाही
ISO C++ forbids declaration of ‘tuple’ with no type
मैं इस समस्या के लिए खोज की है, और ज्यादातर मामलों लोगों में लग रहा था हेडर में std::
या <tuple>
को भूलना। लेकिन मेरे पास दोनों हैं। यहाँ मेरी कोड है:
myclass.h
#ifndef MYCLASS
#define MYCLASS
#include <iostream>
#include <tuple>
class MyClass {
std::tuple<bool, int, int> my_method();
};
#endif
myclass.cpp
#include "myclass.h"
using namespace std;
tuple<bool, int, int> MyClass::my_method() {
return make_tuple(true, 1, 1);
}
अगर मैं बजाय pair
का उपयोग कर, दूसरी int
बाहर छोड़ने और <set>
सहित एक ही है , यह काम करता हैं।
मुझे क्या याद आ रही है?
संपादित करें:
यहाँ पूर्ण उत्पादन होता है:
$ g++ myclass.cpp -o prog
In file included from myclass.cpp:1:
myclass.h:7: error: ISO C++ forbids declaration of ‘tuple’ with no type
myclass.h:7: error: invalid use of ‘::’
myclass.h:7: error: expected ‘;’ before ‘<’ token
myclass.cpp:5: error: expected constructor, destructor, or type conversion before ‘<’ token
$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658)
(LLVM build 2336.11.00)
क्या आपने कोड को संकलित करते समय '-std = C++ 11' निर्दिष्ट किया था? –
'नेमस्पेस std का उपयोग कर;' - क्या निंदा है! –
इस त्रुटि को पुन: उत्पन्न नहीं कर सकता है। क्या आप वाकई इस कोड का उपयोग करते हैं? आपको सटीक लाइन g ++ की सूचना दी जानी चाहिए। – Zeta