typedef error

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
I'm not 100% but I think it should read:

 
typedef std::pair <string, int> mix;
Or add using std::pair; to your code
Last edited on
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.
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.