bind Function and Placeholders in C++

Function template std::bind takes a function as input and generates a forwarding call wrapper. Calling this wrapper is equivalent to invoking input function with some of its arguments. A placeholder forwards argument to the calling function object returned by std::bind. Syntax std::bind is defined in functional header. Below is syntax [...]

By |2020-09-25T15:25:33+05:30September 25th, 2020|Categories: Programming|Tags: |

accumulate and partial_sum Function in C++

std::accumulate() computes the sum of the given elements in the range. std::partial_sum() computes the partial sums of the elements in the subranges of the range. Syntax Below is the syntax of accumulate. template <class InputIterator, class T> T accumulate (InputIterator first, InputIterator last, T init); template <class InputIterator, class T, [...]

By |2020-09-23T18:08:25+05:30September 23rd, 2020|Categories: Programming|Tags: |

copy and copy_if Function in C++

std::copy() and std::copy_if() function in C++ copies the elements in the range, to another range. However std::copy_if() function copies the element based on result of unary function passed to it. Syntax Syntax of copy() and copy_if() function is template <class InputIterator, class OutputIterator> OutputIterator copy (InputIterator first, InputIterator last, OutputIterator [...]

By |2020-09-23T16:51:45+05:30September 23rd, 2020|Categories: Programming|Tags: |

Smart Pointers in C++

Smart pointers in C++ are a wrapper class. It is used to manage dynamically allocated memory and to ensure that the memory gets deleted when the smart pointer object goes out of scope. Smart pointers are just classes that wrap the raw pointer and offer the same syntax (overloaded -> [...]

By |2020-09-03T19:02:46+05:30September 3rd, 2020|Categories: Programming|Tags: |

Difference between Pointer and Reference

A pointer in C++ is a variable that holds the memory address of another variable. A reference is an alias for an already existing variable. Once a reference is initialized to a variable, it cannot be changed to refer to another variable. Hence, a reference is similar to a const [...]

By |2020-09-03T15:25:29+05:30September 3rd, 2020|Categories: Programming|Tags: |

Get Current Thread ID Of Function In C++

std::this_thread::get_id is an in-built function in C++ std::thread. It is an observer function which means it observes a state and then returns the corresponding output. Below is the syntax std::thread::id get_id() noexcept; (since C++11) It returns object of member type thread::id which uniquely identifies the thread (if joinable), or default-constructed [...]

By |2020-07-19T23:00:40+05:30July 19th, 2020|Categories: Programming|Tags: , |

What is Polymorphism in C++

Definition Polymorphism is one of the essential features of object-oriented programming that allows the class object to behave differently at different times. It is divided into two types. Compile time polymorphismRuntime polymorphism Compile Time Polymorphism Compile time polymorphism is also known as early binding or static polymorphism. In this type [...]

By |2020-08-27T16:26:19+05:30June 7th, 2020|Categories: Programming|Tags: |

What is Inheritance in C++

Definition Inheritance in C++ is the capability of one class to acquire properties and characteristics from another class. The class whose properties are inherited by other class is called the Parent or Base or Super class. The class which inherits properties of other class is called Child or Derived or [...]

By |2020-06-07T15:13:44+05:30June 7th, 2020|Categories: Programming|Tags: |

What are Functors in C++

Definition A function pointer allows a pointer to a function to be passed as a parameter to another function. Functors (Function Objects) in C++ allows the function call operator() to be overloaded. It allows instantiated object of a class to be called like a function. Advantages of functor compared to [...]

By |2020-06-06T23:12:49+05:30June 6th, 2020|Categories: Programming|Tags: |

Conversion and Function Call Operator in C++

Definition Conversion Operator is declared like a non-static member function or member function template with no parameters, no explicit return type. They are used to convert between one type and other defined types. It provides a way to implicitly convert an object to its other representation. Function Call Operator is [...]

By |2020-06-06T14:34:47+05:30June 6th, 2020|Categories: Programming|Tags: |
Go to Top