What are ampersands for when used with member declarations? I first noticed it here: [15] Input/output via <iostream> and <cstdio>, C++ FAQ
std::ostream&, what's it for? And what's the dif in effect between pre and post fix.Code:#include <iostream>
class Fred {
public:
friend std::ostream& operator<< (std::ostream& o, Fred const& fred);
...
private:
int i_; // Just for illustration
};
std::ostream& operator<< (std::ostream& o, Fred const& fred)
{
return o << fred.i_;
}
int main()
{
Fred f;
std::cout << "My Fred object: " << f << "\n";
...
}
