never use virtual function for primitives!
why?
they are memory-consuming!
each primitive will contain a table of virtual function pointers, and you will usually have a river of primitives!
so, use virtual function for primitive operator instead! this balance the design and the performance!
treat primitives together as stream,
like this:
class primtive {
};
class primitiveOperator {
public:
virtual void dosomething( void *pointer_to_primitive_array, int num_of_primitives, void *outputs );
...
};
while programming, we can dynamically bind a specified primitive operator to an array of primitives, and the indirect call to the virtual function will only happen once, not one time for each primitive access!