|
|
Warp a écrit :
> Ok, if you want a harder puzzle, here's a curious quirk about C++ (not
> related to memory leaks, though):
>
> a) This doesn't compile. Without using a compiler, can you tell where
> is the problem and what is the exact reason why it doesn't compile?
>
> b) If you can't see it, try it with a compiler. I bet you still can't see
> the problem... :P
>
> c) In the erroneous line, can you tell me exactly what that line means?
>
> d) What is the easiest way (smallest amount of extra code) to make it
> compile and work as expected?
>
Well I have no real idea of what goes wrong but I have a proposition for
d) :-) Down below...
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Replacing
std::map<A, int, Comp> theMap(Comp());
with
Comp c; std::map<A, int, Comp> theMap(c);
seems to do the trick as far as I figure. I don't like those anonymous
objects anyhow ;-)
A trouble with references or some such ? That prevents the full
instanciation of the map template ?
--
Vincent
Post a reply to this message
|
|