Current area: HOME -> C / C++ -> Classes & Objects Articles
Classes & Objects
C++ Classes
For example a building can have walls, windows, height (our variables) but together still remains a building (our class). We can create different instances of buildings, which hold different values (e.g. a house and a office), but they still are part of the building class. Confused? Well we'll try another example. A species is a class of animal (eg a dog); each animal of that class can have certain values (e.g. its age) but each different dog (an object of that class) still remains separate. Lets code this.
Detail about How VPTR and Virtual table works
Assumption: 32-bit Machine.
Here I am going to explain How Virtual table, Virtual pointer for Virtual functions are internally working.
Determining the Size of Class Objects
There are many factors that decide the size of an object of a class in C++. These factors are: 1. Size of all non-static data members, 2. Order of data members , 3. Byte alignment or byte padding and ...
Improving Performance in C++ with Compile Time Polymorphism
Let's take a quick look at using virtual functions and abstract base classes and from there examine a way in which we can improve program performance while retaining the power and flexbility of virtual functions.