I'm trying to compile very simple c++ program by g++ compiler.
//main.cpp
#include <stdio.h>
using namespace std;
typedef pair<int,int> pii;
int main(int argc, char *argv[])
{
printf("Hi");
return 0;
}
But I'm getting compilation error: ‘pair’ does not name a type
Compile line: g++ main.cpp -o main.out OS: Ubuntu 16.04 lts g++: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2)
If I just add #include<iostrem>
program compiles and runs successfully:)
#include <stdio.h>
#include<iostream>
using namespace std;
typedef pair<int,int> pii;
int main(int argc, char *argv[])
{
printf("Hi");
return 0;
}
Do you know, why is this happens?
My fault, answer is easy:)
1) For using pair
I should include <utility>
.
2) <iostream>
somewhere includes <utility>
, that's why after adding it program compiles successfully:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With