|
the name following struct and before the delcaration is what the structure of that name looks like; the name following the struct definition is an alias/synonym for that structure, like in using a typedef.
but that applies to objects, not functions; hence it is used in the constructor (?)
session.cpp:20: error: `session& operator=(const session&)' must be a nonstatic
member function
session.cpp:20: error: `session& operator=(const session&)' must take exactly
two arguments
----------------
(line 20)
session & operator = (const session & other) {
sid = other.sid;
dataMap = other.dataMap;
touched = other.touched;
return *this;
}
(from header -- def)
session & operator = (const session &); // assignment operator
----------- solution -----------------------
use session & session::operator = (const session & other)
http://logic.philosophy.ox.ac.uk/tutorial2/Tut2-01.htm
"Fast jeder C Programmierer hat sich schon mit Zeigern auf Funktionen herumschlagen müssen. Diese kommen immer dann zur Anwendung, wenn eine Funktion als Parameter an eine andere Funktion übergeben werden soll. Beispiele sind die Standard C Library Funktionen bsearch und qsort. "http://cplus.kompf.de/artikel/functors.html
Ein Functor ist ein Objekt, welches operator() definiert.
Functors are function pointers.
Interessant ist auch die Verwendung von vordefinierten Functors als »Callback« Funktionen in den *_if Algorithmen der STL, wie find_if, count_if, replace_if oder remove_if. (see the corresponding names in libptp)
For example, Parser constructor really calls parser_impl();
Parser::Parser(const char* filename)
{
imp = new Parser_Impl(filename);
}