-
std::cout
Just a quick question what does the std:: before cout or cin do for the rogram. I was told that I didnt need that from someone but our teacher makes us use it. Dow anybody know if that is needed for a program to work or why he would make us use it if it isnt?
-
You can use std::cout each time or you can declare it in either of two ways.
Code:
#include <iostream> // Use this for both
using std::cout; // here's one way
using namespace std; // here's another
int main()
{
cout << "Hello world!";
return 0;
}
Using std::cout makes the file smaller, but you then have to declare similar things for every std class function you want to use, like cin, etc. The namespace way brings them all in. For more info on namespace & std, check posts for the last week or so,there's been threads on them there.
-
Hi there!
I recommend you using:
#include <iostream.h>
but not
#include <iostream>
using .....
using namespaces for such things was supposed to be good style, but many programmers asured in the opposite...
Ilia Yordanov,
www.cpp-home.com ; C++ Resources
[email protected]
-
Quote:
Originally posted by Unregistered
Hi there!
I recommend you using:
#include <iostream.h>
but not
#include <iostream>
using .....
using namespaces for such things was supposed to be good style, but many programmers asured in the opposite...
Ilia Yordanov,
www.cpp-home.com ; C++ Resources
[email protected]
That way is ok, but the ANSI/ISO standard is <iostream>, and that's what most textx teach today.