R
Roger
Hello, I'm pretty new to C++ programming, and I'm teaching myself the
language using various sources.
This sounds stupid, but I am really confused on this... I was
wondering why we have to write a C++ program with this:
#include <iostream>
using std::cout;
using std::endl;
int main() {
cout << "hello, world" << endl;
return 0;
}
or like this:
#include <iostream>
int main() {
std::cout << "hello, world" << std::endl;
return 0;
}
Why can't we just write it like this? :
#include <iostream>
int main() {
cout << "Hello, World << endl;
return 0;
}
My compiler, VC++ 2005 Express does not seem to compile the last chunk
of code. Why do we need std? I just need someone to clear up some
confusion. Hehe.
language using various sources.
This sounds stupid, but I am really confused on this... I was
wondering why we have to write a C++ program with this:
#include <iostream>
using std::cout;
using std::endl;
int main() {
cout << "hello, world" << endl;
return 0;
}
or like this:
#include <iostream>
int main() {
std::cout << "hello, world" << std::endl;
return 0;
}
Why can't we just write it like this? :
#include <iostream>
int main() {
cout << "Hello, World << endl;
return 0;
}
My compiler, VC++ 2005 Express does not seem to compile the last chunk
of code. Why do we need std? I just need someone to clear up some
confusion. Hehe.