0

I wrote a simple hello world program:

#include<bits/stdc++.h>
using namespace std;
   
int main(){
   cout<<"Hello";
}

But it is reporting an error:

In file included from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\stl_algobase.h:64,
                 from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\char_traits.h:39,
                 from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\ios:40,
                 from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\istream:38,
                 from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\sstream:38,
                 from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\complex:45,
                 from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\ccomplex:39,
                 from c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\mingw32\bits\stdc++.h:54,
                 from AAY.cpp:1:
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\stl_pair.h:214:11: error: expected unqualified-id before numeric constant
  214 |       _T1 7
      |           ^
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\stl_pair.h: In constructor 'constexpr std::pair<_T1, _T2>::pair()':
c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\stl_pair.h:245:9: error: class 'std::pair<_T1, _T2>' does not have any field named 'first'  
  245 |       : first(), second() { }

and so on.

Basically, it says that std::pair does not have a member named first although I haven't used any. Does anyone have a solution?

Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696

1 Answers1

2

You should not use

#include<bits/stdc++.h>

This is not a C++ compliant header file.

Please use #include <iostream> instead and it should be sufficient.

Of course you may have also a problem with your compiler installation.

Afshin
  • 7,636
  • 1
  • 13
  • 42
Armin Montigny
  • 11,761
  • 3
  • 15
  • 37