I am using the book Teach Yourself C++ in 21 days by SAMS and I am writing my code in the Microsoft Visual C++ 6.0 Professional Edition compiler. I came across this simple example of cout which has made me go crazy
When I compiler this it gives me tons of erros because of the std:: codes. I have never seen this before in C programming at all, and I've programmed in C for about a year now. When I take away all the std:: in front of the cout tags everything compiles except the "std::endl" part. It is supposed to be the ANSI way of making a \n for new line. The error I get is this:Code:#include <iostream.h> int main() { std::cout<<"Hello there.\n"; std::cout<<"Here is 5: "<<5<<"\n"; std::cout<<"The manipulator std::endl "; std::cout<<"writes a new line to the screen."; std::cout<<std::endl; return 0; }
error C2653: 'std' : is not a class or namespace name
Can someone first please explain why std:: is everywhere in this book. I've searched for hours in old textbooks and the infamous google, but I cannot find good explanations. All my friends say they never use std::...I can accept this, but I can't accept that it won't compiler since it is supposedly ANSI compliant. Can experienced C++ programmers please help me.
Thanks
Hern



LinkBack URL
About LinkBacks




