C++ Explicit

What is explicit keyword? A constructor that takes a single argument operates as an implicit conversion operator by default. This is also referred as converting constructor. To prevent this implicit conversion keyword explicit has been introduced in C++. This makes the constructor as non-converting. This keyword has effect only when defined on a single argument …

C++ Explicit Read More »

C++ RTTI

What is RTTI? RTTI stands for Run-time Type Identification. RTTI is useful in applications in which the type of objects is known only at run-time. Use of RTTI should be minimized in programs and wherever possible static type system should be used. RTTI allows programs that manipulate objects or references to base classes to retrieve …

C++ RTTI Read More »

Chain of Responsibility

What is Chain of Responsibility Pattern? Chain of Responsibility is a behavioral design pattern. The basic idea behind this pattern is that a request or a command passes through a chain of objects until it is handled. Objects involved in this pattern are of two types. Processing Objects and Command Objects. Processing objects handle the commands …

Chain of Responsibility Read More »

About Design Patterns

What is a Design Pattern? Design patterns describe recurring software design problems and their solutions. Design patterns assign in reuse of software architectures. Design patterns are independent of any programming language and they don’t talk about code re-use. The book “Design Patterns: Elements of Reusable Object-Oriented Software” also referred as “GoF (Gang of Four) Book” …

About Design Patterns Read More »

C++ References

What are references in C++? Reference variables are aliases to other variables. Any changes to the original variable or the alias (reference variable) result in change to the same memory location. Reference variables must always be initialized. When pass by reference is done to functions unlike pass by value a new copy of the variable …

C++ References Read More »

C++ Placement New

What is placement new in C++? In some scenarios it becomes necessary to place objects at specified locations in memory. Placement new solves this problem. For example, there could be predefined memory pools in which certain objects need to be placed on creation. Placement new is achieved by overloading the new operator which takes more …

C++ Placement New Read More »

C++ new and delete

How is dynamic memory management handled in C++? C++ supports the operators new and delete for dynamic memory management. These operators perform both allocation/ deallocation of memory and initialization/ cleanup of objects. The class constructor is automatically called when the object is created and the destructor is called when the object is destroyed. The new …

C++ new and delete Read More »

C++ this pointer

What is this pointer? Every object has a special pointer “this” which points to the object itself. This pointer is accessible to all members of the class but not to any static members of the class. Can be used to find the address of the object in which the function is a member. Presence of …

C++ this pointer Read More »

C++ Object Slicing

What is object slicing? Object slicing is a concept where additional attributes of a derived class object is sliced to form a base class object. Object slicing doesn’t occur when pointers or references to objects are passed as function arguments since both the pointers are of the same size. Object slicing will be noticed when …

C++ Object Slicing Read More »

C++ Inline Functions

What are inline functions? Inline functions help to avoid the performance overhead associated with function calling when there are too many calls to a really small function. Code of an inline function would be inserted at every point of function call by the compiler. Adding the keyword inline is just an instruction to the compiler …

C++ Inline Functions Read More »