Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Using "using" statements...

1) I noticed that a lot of people are using the File 2 version... Why? (I know why namespace exists in the langauge, so you don't need to explain about that).
2) What is the different between #include <iostream.h> and #include <iostream>?

// File 1
#include <iostream.h>

int main()
{
  cout << "Hello" << endl;
  return 0;
}

// File 2
#include <iostream>

using std::cout;
using std::endl;

int main()
{
  cout << "Hello" << endl;
  return 0;
}
0
chaos_hooi
Asked:
chaos_hooi
1 Solution
 
AxterCommented:
<iostream.h> is NOT part of the C++ standard, where as <iostream> is part of the C++ standard.

The *.h version is included in most compilers for backward compatibility.

You should avoid using the *.h version, and use the extensionless version.

Since the *.h version is not part of the standard, it can, and is different from one compiler to the next.
0
 
fl0ydCommented:
From the thread title I guess you are interested in why there is 'using std::cout;' as opposed to 'using namespace std;'. It is sort of a compromise between the ugly and dangerous std::-namespace resolution into global namespace and reduced typing. It only brings those symbols that you actually plan on using into global namespace and is favoured over the 'using namespace ...;', yet I don't use either on, as this causes potential ambiguities. As a matter of personal taste I believe that 'std::cout << ...' is easier to read than 'using std::cout; cout << ...', but opinios differ on this one.

.f
0
 
chaos_hooiAuthor Commented:
Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now