[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppCout
In C, printf is used instead.
However using operator overloading on the stream out operator '<<' gives you the ability to define how your class will be cout-ed.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
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 <<.int main() { std::cout <<"Hello World" << std::endl; }
- include <iostream>
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
- #include
- <<, Stream out operator.
- endl
- include
- int
- iostream (header file)
- std
- std::endl
- Stream out operator, <<
Reference
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
