1. What is a virtual? 2. If class has virtual function, what happens in compile time and in run time? 3. What is a polymorphism? 4. Write the function that gets array of chars and returns number of elements with 3 bits ON, performance is important. 5. Write the function that draws a line from x1,y1 to x2,y2 6. You have very long function with many return statements. You have to determine how much time it runs.
Sigiloso
2. in C++, when a class defines has at least one Virtual Function, an extra pointer is added to the class definition called Virtual Table Pointer (aka vptr) which points to a Table containing Function Pointers. (each Class defines it's own VirtualTable). when an object is created, just before calling the constructor, the VPTR is set to the Table of the actual created object (actually it get overwritten by the deriving objects) lastly, any call to a Virtual function is not called directly, but through its corresponding pointer (*vptr[fidx])().