On Feb 8, 7:57 pm, suresh shenoy <msureshshe...@gmail.comwrote:
I came across a snippet of code which I was not able to interpret
correctly.
typedef CategoryStream& (*cspf) (CategoryStream&);
Declares cspf as a pointer to a function which returns a
CategoryStream&, and has a single parameter of type
CategoryStream&.
CategoryStream& CategoryStream::operator<< (cspf pf) {
return (*pf)(*this);
}
First, this is the implementation of a member function; it will
be called in expressions like:
CategoryStream s ;
s << someFunction ;
If anyone could explain each line, it would be great!
It's the standard idiom for a manipulator not taking any
arguments in a stream. See, for example, things like std::hex,
std::uppercase, etc., and the way they work in std::ostream&.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34