Wednesday, 21 August 2013

Why does the cost of C++ virtual call depends on the number of derived classes?

Why does the cost of C++ virtual call depends on the number of derived
classes?

I've written a short example program that I was using to study the
overhead of virtual calls.
File virtual.h:
#pragma once
static const int NUM_DERIVED = 10;
struct Base {
int val;
#ifdef NO_VIRTUAL
#define virtual

No comments:

Post a Comment