POV-Ray : Newsgroups : povray.off-topic : Smart little programming tricks, where to find ? : Re: Smart little programming tricks, where to find ? Server Time
11 Oct 2024 01:21:38 EDT (-0400)
  Re: Smart little programming tricks, where to find ?  
From: Warp
Date: 20 Mar 2008 03:45:39
Message: <47e22433@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.