Category: C++

C++: Operator Overloading

One of the beautiful feature of ‘C++’ is its ability to support Operator Overloading. ‘C++’ Operator Overloading allows to change the behavior of operators when using them with ‘C++’ class objects. One of the best example of Operator Overloading is…

C++: Inheritance

Inheritance allows to reuse the functionality. Inheritance inherits base class members to derived class. We can use base class members within derived class without rewriting base class code. C++ allows single inheritance as well as multiple inheritance. In single inheritance, derived…

COM: Creating a COM Component using C++ (Part-11)

Finally we have successfully developed our COM component HelloComponent using C++. Lets summarize how we develop our COM component in this article. Microsoft’s Component Object Model (COM) is a specification to allow to write re-usable components and enables them to communicate each…

C++: Templates

C++ Templates are used for writing generic programming. C++ allows to define function templates and class templates. In C++, we use template keyword to write generic programming. The syntax of the template declaration starts with template<class T> Where template is…

COM: Creating a COM Component using C++ (Part-10)

CoCreateInstance is depends on IClassFactory to create class instances. We have looked into IClassFactory‘s methods and we have implemented these methods in our previous article. Lets include IClassFactory‘s implementation into our HelloComponent. We already have HelloComponent‘s declaration in “HelloComponent.h” file and its…

COM: Creating a COM Component using C++ (Part-9)

In our previous article, we have identified that CoCreateFunction is requesting an instance of IClassFactory. Why CoCreateInstance is requesting an instance of IClassFactory? One of the goal of the COM is locate the objects easily without worrying about where they are located and…

COM: Creating a COM Component using C++ (Part-8)

As we discussed in our previous articles, COM’s CoCreateInstance function is used to create instances for COM classes. When the client program calls CoCreateInstance to create an instance of COM class: It actually internally calls another function CoGetClassObject CoGetClassObject checks the…

COM: Creating a COM Component using C++ (Part-7)

When we run our test application, we were getting a message “No such interface supported”. It seems, CreateInstance was failed to return the instance of the component. Before looking into the way CreateInstance creates an instance of our component; let us test…

COM: Creating a COM Component using C++ (Part-6)

DLL with exported functions showing in Microsoft's Dependency Walker Tool

In previous article, we have created a test application to test our COM component. When we rant our test application, it was displaying “Class not registered” error message. Before re-looking into our component and test application code; lets understand in what scenarios…

C++: Why virtual? (Part-3)

Another interesting feature of Object Oriented Programming is its inheritance. Inheritance inherits the behaviors or attributes from its parent or base classes. C++ uses virtual inheritance to overcome the inheritance ambiguity in multiple-inheritance. Inheritance ambiguity will occur when derived class object is…

C++: Class Constructors

In C++, Class constructors are special kind of methods to instantiate a class. When class’s object is going to create, first C++ will call class’s constructor to initialize the class. Initialize the class means, assigning its members and allocating any…

MFC: Convert C++ Class to MFC based class

Microsoft Foundation Classes (MFC) are used to develop Windows based applications. MFC supports Document-View architecture; where data management separates from presentation layer. MFC wraps portions of Windows API C++ classes and enables to use them easily. In this article, we…

C++: Why virtual? (Part-2)

An interface is a contract between a caller and a callee. An interface doesn’t provide any implementation. It provides a blue-print. C++ uses virtual keyword to create an interface or an abstract class. Lets take an example: class IHello {…