When I try to compile a simple class ( g++ myclass.cpp ), I get the following error:
ISO C++ forbids declaration of 'tuple' with no type
I was looking for this problem, and in most cases, people seemed to forget std:: or including <tuple> in the header. But I have both. Here is my code:
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); }
If I do the same with pair , leaving the second int and including <set> will work.
What am I missing?
EDIT:
Here is the complete conclusion:
$ 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)
Jawap source share