Which is faster ?View more random threads:
- Programme Not Run in C++ giving erros 2011
- pasting my code down # include main () { char endp; char...
- latest C++ Books 2011
- what are instance variable in c++ ?
- can we use Microsoft Visual Studio Ultimate 2010 for...
- I wanted to program this in a manner that it will display
- what this function do ? void student ::setName (char...
- Passing 2d array by reference June 2011
- what is an argument in c++?
- HUFFMAN ENCODING in C++ 2012
A. Call 1000 times a virtual function OR
B. call 1000 times a normal function trough a function pointer.
For example:
A.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class Base
{
public: virtual void myfunc() = 0;
};
class Child: public Base
{
public: void myfunc(){...}; //overriding the base class function
}
int main()
{
Child myclass;
call myclass.myfunc() 1000 times
}
B.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class SomeClass
{
public: void myfunc(){ ... }
};
int main()
{
SomeClass myclass;
void (*foo)();
foo = &myclass.myfunc;
call foo() 1000 times
}
Sponsored Links
What do You guys think which one would perform better ?
Assume that the compiler will surely not be able decide the class type in the virtual function case (A). And also the functions are quite complex and big.
Urgent call: 03455242488. | Virtual University Assignments
Virtual University GDBs | Virtual University Papers | Vu Projects | Vu Handouts
About Expert
There are currently 1 users browsing this thread. (0 members and 1 guests)