help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: swap in stdlib?


From: Ulrich Eckhardt
Subject: Re: swap in stdlib?
Date: Mon, 27 Feb 2006 08:06:07 +0100
User-agent: KNode/0.9.3

schuelaw@gmail.com wrote:
> Thanks for this.  I'm beginning to understand a bit more.  Just to
> clarify (if you will), I notice that the original program that raised
> this issue had an #include <iostream> at the top because the student
> was using cout.  

Please also tell your students that including <iostream> is not enough to
use std::cout, it is only guaranteed to be declared. If you want to output
something, you also need <ostream>. Most standardlibraries indirectly
include <ostream> into <iostream> though, so it works most of the time.

> If I remove that line, then the swap function becomes 
> unrecognized.  So for some reason, iostream is prototyping swap either
> directly or indirectly.

Right, but just as with above iostream/ostream, this is not something you
should rely on. Only by including <algorithm> you are guaranteed to get
std::swap().

Uli

-- 
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]