We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: in

When to use virtual functions in C++?

When we want a Derived Class to override a member function of Base class, then we should make that member function in Base class virtual. So that if someone uses the Derived class object using Base class’s pointer or reference to call the overridden member function, then function of derived class should be called. Suppose draw() is …

When to use virtual functions in C++?Read More

C++ : Map Tutorial Part 3: Using User defined class objects as keys in std::map

In this article we will discuss how to use User defined classes as key in std::map. By default std::map uses “operator <” as sorting criteria for keys. For default data types like int and std::string etc, operator < is available by default but for User defined classes operator < is not available by default. Advertisements …

C++ : Map Tutorial Part 3: Using User defined class objects as keys in std::mapRead More

Designing Code to Convert the base of a Number to any other base in Number System

In this article we will discuss how to design a Class that represents the Number in a Number System and also provides the facility to convert the Base associated with that Number i.e. conversion from any Base to any other base like, octal to hexa or hexa to decimal etc. [showads ad=inside_post] Create a class Number that …

Designing Code to Convert the base of a Number to any other base in Number SystemRead More

Using STL to verify brackets or parentheses combination in an expression

In this we will see how to check if a given string take valid combination of open and close brackets i.e. (4+{8-[22+8]*}] contains valid order of open and close brackets. ({5+8]) contains invalid combination of open and close brackets. Advertisements [showads ad=inside_post] Bracket combinations to be used, Frequently Asked: Using STL to verify brackets or parentheses combination in an …

Using STL to verify brackets or parentheses combination in an expressionRead More

Designing a Multiton: Singleton that returns 5 objects in cycle

Let’s Design a Multiton class i.e. a modified Singleton to return 5 objects in cycle. Logic to Create Multiton Advertisements Instead of keeping a static pointer as member variable keep a vector of pointers as member variable. Now also keep track of how many times getInstance() function is called. To do that use static member …

Designing a Multiton: Singleton that returns 5 objects in cycleRead More

Allocating and deallocating 2D arrays dynamically in C and C++

In this article we will see how to allocate and deallocate 2D arrays dynamically using new / delete and malloc / free combinations. Suppose we want to create a 2D array using pointers on heap either using new or malloc. It should function like this, Advertisements int row = 2; int col = 3; int ** …

Allocating and deallocating 2D arrays dynamically in C and C++Read More

Remove all occurences of an element from vector in O(n) complexity

Suppose we have a vector of integers and we want to delete all occurences of a number from it i.e. Let’s say vector contain following numbers 1,2,5,4,5,1,5,7,8,9. Now we want to delete all the occurences of 5 from it, so that vector contents should become – 1 2 4 1 7 8 9 . Also …

Remove all occurences of an element from vector in O(n) complexityRead More

Creating Custom Modules in node.js using exports and module.exports

Modules are like reusable components that can be used across applications. It’s like encapsulating a functionality in a separate module. Benefits of modules in node.js: Advertisements 1.) Code re-usability 2.) By delegating separate functionality to individual modules, code becomes modular. In node.js modules, we can expose functions and variables to outside world. Frequently Asked: Creating …

Creating Custom Modules in node.js using exports and module.exportsRead More

Need of Factory Method Design Pattern in Frameworks Explained

Factory Method Design Pattern

In a framework we deal mainly with abstract classes. Application that is going to use our framework provides the derived classes these abstract classes. Let’s understand by an example of Thread pooling Framework, A thread pooling framework provides the facility to execute Tasks in pooled environment by worker threads. It’s doesn’t know what actually the …

Need of Factory Method Design Pattern in Frameworks ExplainedRead More

Cart

Your Cart is Empty

Back To Shop