June 3rd, 2010, 2:26 pm
Here is a previous post by Luigi (QL) on another thread:QuoteOn what compiler, and what optimization level?On my Mac OS X machine:gcc 3.3, no optimizations:Non-virtual: 25.81Virtual: 54.91gcc 3.3, full optimization:Non-virtual: 2.02Virtual: 22.88However, my compiler is a bit old. They might have got better at optimizing virtual functions. I'll be able to try gcc 4 when I get back to my office (in a week.)You might try cranking up your optimization level, though.LuigiP.S. You have the virtual function at a disadvantage. In the linetemp = myObject -> funcV();the return value has to be converted from double to int to be assigned to temp. You might want to declare a double temp2 to assign to (that's what I did) or change the virtual function so that it returns an int.
Last edited by
Cuchulainn on June 2nd, 2010, 10:00 pm, edited 1 time in total.