|
|
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
> Oh I think I know. I took a while without noticing anything wrong, but
> now I remember having read about it in C++ FAQ Lite. theMap(Comp())
> *declares a function* instead of instantiating an object.
But why? Doesn't "Comp()" create an object? How can you declare a function
with an object (instead of a type)?
What kind of function? What does it return? Does it take parameters?
What is the type of those parameters?
> The solution is:
> std::map<A, int, Comp> theMap = Comp();
Alternatively you can do:
std::map<A, int, Comp> theMap((Comp()));
(which would be necessary if the map constructor took more than one such
parameter...)
--
- Warp
Post a reply to this message
|
|