We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Function

Iterating over a range of User Defined objects and calling member function using std::for_each

In this article we will discuss how to iterate over a container of user defined objects and call a member function on each of the iterating element.Suppose you have a vector of Employee class objects and you want to call a member function on each of the element in vector. [showads ad=inside_post] Let’s see how …

Iterating over a range of User Defined objects and calling member function using std::for_eachRead More

Designing Callbacks in C++ – Part 1: Function Pointers

Callback Mechanism Exmplained

In this article we will discuss what is a callback and what types of callbacks we can have in C++ and how to Design Callbacks as function pointers. Now what is a callback? Advertisements Callback is a function that we pass to another APIs as argument while calling them. Now these APIs are expected to …

Designing Callbacks in C++ – Part 1: Function PointersRead More

Designing Callbacks in C++ – Part 2: Function Objects & Functors

In this article we will discuss, what is a Function Object, why do we need function objects and how to use function objects as Callbacks. What is a Function Objects: Advertisements A Function Object / Functor is a kind of Callback with State. In a Programmer’s terminology, Frequently Asked: Designing Callbacks in C++ – Part …

Designing Callbacks in C++ – Part 2: Function Objects & FunctorsRead More

How to pass variable arguments in a function

In this article we will discuss how to pass variable number of arguments in a function. Requirement: Advertisements Suppose I want to create a function that take variable number of arguments and use them to perform some task. For example, Create a function that will return the sum of all the passed arguments i.e. Frequently …

How to pass variable arguments in a functionRead More

Using unordered_set with custom hasher and comparision function

In this article we will discuss how to use std::unordered_set custom hasher and comparision function. Unordered_set uses the Hash table implementation to provide the set functionality. To know more about Hash Table visit the following article, Advertisements What is Hashing and Hash Table? Whenever we insert an element in unordered_set two things happen i.e. Frequently Asked: std::unordered_set …

Using unordered_set with custom hasher and comparision functionRead More

Passing Variable Arguments to a function in Java using varargs – Tutorial & Example

In this article we will discuss how to pass variable number of arguments of a type in a function in java using varargs. Passing Variable Arguments to a function Let’s write a function that accepts variable number of same type for example int in this case i.e. Advertisements Calling function with 2 arguments i.e. two …

Passing Variable Arguments to a function in Java using varargs – Tutorial & ExampleRead More

C++11 : Start thread by member function with arguments

In this article we will discuss how to start a thread by a member function of class. Starting thread with non static member function Suppose we have a class Task, which has non static member function execute() i.e. Advertisements class Task { public: void execute(std::string command); }; Now we want to start a thread which …

C++11 : Start thread by member function with argumentsRead More

C++11 – Variadic Template Function | Tutorial & Examples

Variadic Template is introduced in C++11. Variadic Template allows a function to take variable number of arguments of any type. Let’s understand by an example. Advertisements Suppose we want to create a function log() that accepts variable number of arguments of any type and prints them on console i.e. log(1,4.3, “Hello”); log(‘a’, “test”, 78L, 5); class Student; Student …

C++11 – Variadic Template Function | Tutorial & ExamplesRead More

C++ : How to pass class member function to pthread_create() ?

POSIX Library provides a function pthread_create() to create threads i.e. #include <pthread.h> int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); It accepts a function pointer as startup routine. This function accepts void * as argument and returns void *. In previous article we discussed how to use this API with global functions …

C++ : How to pass class member function to pthread_create() ?Read More

Cart

Your Cart is Empty

Back To Shop