Skip to main content
gamedev.net
🔒 Locked

printf and cout

Started by MrPoopypants 1 reply 300+ views
Original Post
MrPoopypants
MrPoopypants
Whats the difference in C++?
(0110101101000110)The Murphy Philosophy: Smile . . . tomorrow will be worse.
Vohaul
Vohaul

A world:

http://www.cplusplus.com/ref/cstdio/printf.html

http://www.cplusplus.com/ref/iostream/cout.html

EvilTachikoma
EvilTachikoma
You can also do things like this...


  

struct rect
{
int x, y, w, h;
}

ostream& operator << (ostream &s, const rect *r)
{
s << "The width and height of the rectangle are " << r->w << " and " << r->h << ", it is positioned at coordinates " << r->x << " and " << r->y;
return(s);
}



Since cout is an initiation of the ostream class, you can only guess what cout will output when I pass it an object of type rect. The wonders of operator overloading :-).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.