I can't get STL pair to work

R

razael1

#include <utility>
#include <vector>

using namespace std;

vector< pair<int,int> > v;

Generates an error: ISO C++ forbids declaration of 'vector' with no
type

I'm using MinGW/Dev-C++ compiler. The file "utility" includes
"bits/stl_pair.h", which contains the class pair in the std namespace.
What's wrong?

Thanks,
CK
 
P

Pete Becker

#include <utility>
#include <vector>

using namespace std;

vector< pair<int,int> > v;

Generates an error: ISO C++ forbids declaration of 'vector' with no
type

I'm using MinGW/Dev-C++ compiler. The file "utility" includes
"bits/stl_pair.h", which contains the class pair in the std namespace.
What's wrong?

No idea. You'll have to do some experimenting. It's not obvious from the
error message that the problem is pair. So try a few things:

pair<int, int> p;
vector<int> v;

If either of those fails, you've narrowed down the problem.

--

-- Pete

Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." For more information about this book, see
www.petebecker.com/tr1book.
 
I

Ian Collins

#include <utility>
#include <vector>

using namespace std;

vector< pair<int,int> > v;

Generates an error: ISO C++ forbids declaration of 'vector' with no
type

I'm using MinGW/Dev-C++ compiler. The file "utility" includes
"bits/stl_pair.h", which contains the class pair in the std namespace.
What's wrong?
Nothing obvious.

Try instantiating a vector<int> and a pair<int,int> and see which barfs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top