Nov 8, 2010 at 5:17pm Nov 8, 2010 at 5:17pm UTC
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:17pm UTC
Nov 8, 2010 at 5:21pm Nov 8, 2010 at 5:21pm UTC
Or add using std::pair;
to your code
Last edited on Nov 8, 2010 at 5:22pm Nov 8, 2010 at 5:22pm UTC
Nov 8, 2010 at 5:24pm Nov 8, 2010 at 5:24pm UTC
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 Nov 9, 2010 at 2:47pm UTC
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.