[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppClx » VBDOS » CppDataType » PCI BUS » jumper » userpage » rs 485 » CppStreamOutOperator » CppStreamInOperator » highlevel » CppCout

(C++) std::cout

'cout' stands for 'Character Output' [1]. It is a stream writing to the screen. Do do so, you use the stream out operator <<.

  1. include <iostream>
int main() { std::cout <<"Hello World" << std::endl; }


In C, printf is used instead.

From [1] : How do you pronounce "cout"?

"cout" is pronounced "see-out". The "c" stands for "character" because iostreams map values to and from byte (char) representations.

Errors

Undefined function 'cout'

The program does not know what cout means. Checklist:
  • Did you misspell '#include <iostream>
  • Did you misspell 'std::cout'?
  • Did you misspell 'using namespace std;'?
  • The line before, did you forget a semicolon?

No match for std::ostream& << MyClass&' operator

Probably you tried to cout a class, instead of one of its member variables:
MyClass myClass; 
std::cout << myClass << std::endl; //Cannot cout a class
std::cout << myClass.getValue() << std::endl; //Correct


However using operator overloading on the stream out operator '<<' gives you the ability to define how your class will be cout-ed.

Code links

Reference



last edited (November 5, 2006) by bilderbikkel, Number of views: 23858, Current Rev: 22 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.