problem with multimaps and virtual functions
The problem I have having is slightly odd. Am not sure if it is specific to gcc but anyway.
I am creating a multimap container <double,scatter> where scatter is a parent class. I am then populating the map with a number and a child object. with in the class there is a call to a virtual function which is different for different child objects, however when I trace the function call in gdb(debugger) it seems to call the parent class function instead of the desired child class.
if the viftual fuction is called foo then the call is with the code
Code:
prob = RandomNumber() * totalprob;
sc_mapi = scattering_map.begin();
for (double probcount=0; probcount<prob; ++sc_mapi)
{
probcount +=sc_mapi->first;
}
sc_mapi->second.foo();
where sc_mapi is an iterator and totalprob is the sum of all doubles in the map. If you can see anything wrong with the implementation here or have had a similar problem ..any help would be great.
Thank in advance.