Note: After Re-Branding 9Lean is now CodesBay -------------------------------------------------------------------------------- The C++ Virtual Keyword is one...
The C++ Virtual Keyword: Nothing Dynamic or RunTime about it
seen from China

seen from Malaysia
seen from United States
seen from France

seen from Pakistan

seen from United Kingdom

seen from India
seen from India
seen from Malaysia
seen from United States
seen from United States

seen from Malaysia
seen from China
seen from Algeria
seen from China
seen from Italy
seen from China
seen from United States

seen from Pakistan
seen from China
Note: After Re-Branding 9Lean is now CodesBay -------------------------------------------------------------------------------- The C++ Virtual Keyword is one...
The C++ Virtual Keyword: Nothing Dynamic or RunTime about it

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Inheritance + Virtual Functions = Polymorphism
Continuing my post on INHERITANCE to INHERITANCE AND POLYMORPHISM Hope u guys hav read dat if not den plz read dat before reding dis....!! Inheritance is powerful but still u vil think dat v can do without it. Obviously yes .... v can, v have been doing without it coz v still use C language. But introucing d concept of POLYMORPHISM with inheritance takes d power to the next level. So remember INHERITANCE + POLYMORPHISM = VERY POWERFUL We introduce d concept of polymorphism by introducing VIRTUAL FUNCTIONS. So u should first understand d concept of Virtual functions. For eg: We create an ENEMY class and we have 20 different types of ENEMIES class enemy { public: void Attack(); } So dis becomes our base class for all enemies now if we have like 20 diff. enemies in our game and all of dem have different attacks. So without using Virtual functions we make 20 classes for diff enemies and all of dem inherit from base class enemy. den enemy obj = new badEnemy(); enemy obj1 = new BadAssEnemy(); enemy obj2 = new RealBadAssEnemy(); but when we call attack() of all three objects it will call d attack() of base class.....:( so bad na same kind of attack for every enemy makes ur game a dull game, UNTIL we make dat attack() function "VIRTUAL". Now each enemy class vil have different implementation for their attack() which vil actually make dem different. like badenemy attack() simply fires a pistol at you while BadAssEnemy's attack() fires a machine gun at you and RealBadAssEnemy's attack() fires rocket launcher at u..!! Hope ur following d point..it gives us d power to implement d function differently for every class.
Basics of Virtual Functions
WORKING OF VIRTUAL FUNCTIONS The address of all the functions are known at compile time with the exception of virtual functions. There address is not known at until run time, this is an example of late binding. One of d factors deciding the size of an executable (.exe) depends on this binding if a lot of early binding is done d size tends to increase and with late binding the size tends to decrease. In the world of VIRTUAL functions there are "VTABLES" and "VPTRS" VTABLES: They are an array of function pointers which holds the addresses of all the virtual functions. Only 1 VTABLE is generated for a single class VPTRS: It is a pointer which points at a location inside the VTABLE.Each object will have a VPTR which points to the correct location in a VTABLE. SO what happens when we call a virtual function 1.VPTR of that object is fetched 2.Offset in the VTABLE is calculated 3. At that offset is d function pointer which is pointing to the virtual function which is then fetched 4. finally the function call is made. Though the actual memory footprint of a virtual function is very complex but dis is d crux of what happens behind and should give u a basic understanding. NOTE: Compilers are smart enough to optimize VIRTUAL function calls. For eg: class A { virtual void func(); } class B : public A { virtual void func(); } int main() { A* obj = new B(): B* obj1 = new B(): obj.func(); \\Virtual function overhead, VTABLE lookup occurs here obj1.func(); \\No overhead here simple member function call passing a "this" pointer. return 0; }
Learning COM Concepts
Recently, I've had the privilege of learning COM at work. I dealt a tiny bit with it during my internship, but not at the same depth as now. I had never really took the time to take in the concepts of COM, but now, I am more aware that when learning about something, it's best to dig into the concepts before the details. So, without further ado, I introduce my (most current) summary of COM concepts (which will be built upon as I keep learning):
* coclasses
* interfaces
* class factories
* component housing
About coclasses:
The term "coclass" is just a fancy term for a COM object. A COM object inherits from at least one abstract class - IUnknown. The inherited abstract class is a way to define an "interface". An interface can be thought of as a contract signed by the COM object which says that the COM object MUST implement the methods declared in the abstract class. The code that wants to call the COM object's methods will actually call them indirectly through those interfaces...
About interfaces:
The IUnknown abstract class declares three methods, which the COM object must implement, or else, it too will become abstract. Remembering the concept of C++ pure virtual methods is really helpful here. Whatever code (we'll call it the client) is interested in using the COM object will actually be given the pointer to the COM object's virtual function table pointer! In this way, the client will be able to call the methods that the COM object was forced to implement because of what it inherited from its abstract classes. Remember that the virtual function table is just an array of function pointers. These function pointers point to the actual implementation of the methods mentioned in the abstract class inherited by the COM object. When it comes to creating the COM object, the client code doesn't do this directly. The client code actually goes through class factories...
About class factories:
A class factory is just a COM object whose soul purpose is to create one kind of COM object when it is requested to do so by the client code. When a class factory processes a client's request for a COM object, it creates an instance of the COM object and then returns a pointer to its interface to the client that made the request. The client, having the pointer to the COM object's interface, can now make calls to run the COM object's methods. The COM object and class factory live together in what's called the component housing...
About component housing:
We need to remember that COM objects don't just sit in memory as .obj files. They must live in some kind of binary packaging. We call this the component housing. These component housings can either be DLLs or executables. In general, the COM runtime is responsible for loading the COM objects from these binary packages, so that the client code can use them.
Well, that's about it for my COM concepts summary, so far. I still have more to learn about COM, so as I go along, I'll make up more summaries to add to this one.