typedef error

Nov 8, 2010 at 5:17pm
Hello, Good day to everyone !

This question sure has a simple answer, Look at the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <vector>

using std::string;
using std::cout;
using std::cin;
using std::endl;
using std::vector;

int main() {
	typedef pair <string, int> mix;	
	return 0;
}


This code here is throwing the following error:
error: expected initializer before '<' token

I have read the documentation, and have found nothing about what could possibly be generating such error.
Please help me !
Last edited on Nov 8, 2010 at 5:17pm
Nov 8, 2010 at 5:19pm
I'm not 100% but I think it should read:

 
typedef std::pair <string, int> mix;
Nov 8, 2010 at 5:21pm
Or add using std::pair; to your code
Last edited on Nov 8, 2010 at 5:22pm
Nov 8, 2010 at 5:24pm
Oh gOsh, that totally worked ! thank you guys, I keep forgetting almost everything should be taken from the standard library using the scope operator.

It's kind of embarassing for me to be asking such simple questions, but your answers are totally welcome nonetheless. Thank you guys,

Jose.
Nov 9, 2010 at 2:47pm
Also, std::pair<> is declared in <utility> so you should include that header.
As it stands you are getting it gratuitously through iostream or vector.
Topic archived. No new replies allowed.