The basic question of including a C ++ header?

What is the difference between below 3 programs? <iostream> header file or C ++ standard library?

1.

#include<iostream>
using namespace std;

int main()
{
        return 0;
}

2.

#include<iostream>

int main()
{
        return 0;
}

3.

#include<iostream.h>

int main()
{
        return 0;
}

Thanks in advance.

+5
source share
4 answers

As for the program being created, there is zero difference - since nothing in the library iostreamrefers to the program, none of the libraries will be compiled by any intelligent compiler.

#include <iostream>, iostream. #include <iostream.h> #include <iostream>, , , std:: - , iostream, .h. ( <iostream.h> , char.)

using namespace std; , std, , . , std::, , , -, .

+13

3 :

iostream.h . ( g++ GNU libstd++). , , .

iostream.h , ++ 1998 . 98 <iostream.h> <iostream>, ( ) . , , . , , .

+3

iostream - , , ++.

"iostream" ( ), ( #include s) , #include <iostream>.

#include , "". , , , . ++ ++, , .

, using namespace std . , , , cout string , std::cout std::string. , .

, iostream ++, (2), (1) , (3) , (2) std:: ( , ), (3) "iostream.h" "iostream", , .h pre-standard ++ .

+2

++, <iostream.h>

In the 1st program, using namespace stdintroduces the entire namespace into the space std.

See this one for more information.

+1
source

All Articles