Commonly Used Macro in C/C++

Print function name in C printf("%s", __func__); Print line number and file name in C/C++ #define print(a, args...) printf("%s(%s:%d) " a, __func__,__FILE__, __LINE__, ##args)

By |2021-03-05T19:01:48+05:30February 26th, 2021|Categories: Programming|Tags: |

Boost.Bind | C++

Introduction boost::bind is a generalization of the standard functions std::bind1st and std::bind2nd. It supports arbitrary function objects, functions, function pointers, and member function pointers. Syntax Below syntax bind function with parameters. boost::bind(namespace::functionName, _1, _N); To bind a member function, an instance of an object on which the member function can [...]

By |2020-02-22T22:13:16+05:30January 27th, 2020|Categories: Programming|Tags: , |

constexpr specifier in C++

constexpr constexpr specifier declares that it is possible to evaluate the value of the function or variable at compile time. The main idea is performance improvement of programs by doing computations at compile time rather than run time. It specifies that the value of an object or a function can [...]

By |2020-08-27T21:39:28+05:30September 11th, 2019|Categories: Programming|Tags: |

Type Inference | C++

Type Inference refers to automatic deduction of the data type of an expression in a programming language. Before C++ 11, each data type needs to be explicitly declared at compile time, limiting the values of an expression at runtime but after the new version of C++, many keywords are included [...]

By |2019-09-11T21:29:26+05:30September 11th, 2019|Categories: Programming|Tags: |

typeid operator | C++

The typeid operator returns a const reference to a type_info object that describes type-id or the type of expression. If expression is an lvalue (not a pointer) of a polymorphic class, the type_info of the most-derived class is returned. Otherwise, expression is not evaluated, and the type_info of its static type is returned. Each distinct type has its own associated type_info object, but type synonyms (such as [...]

By |2019-09-11T21:10:56+05:30September 11th, 2019|Categories: Programming|Tags: |

Enum | C++

Introduction An enumeration is a distinct type whose value is restricted to a range of values, which may include several explicitly named constants ("enumerators"). The values of the constants are values of an integral type known as the underlying type of the enumeration. There are two distinct kinds of enumerations: [...]

By |2019-09-10T23:27:34+05:30September 10th, 2019|Categories: Programming|Tags: |

l-values and r-values | C++

In C++, variables are a type of l-value (pronounced ell-value). An l-value is a value that has an address (in memory). Since all variables have addresses, all variables are l-values. The name l-value came about because l-values are the only values that can be on the left side of an assignment statement. [...]

By |2019-09-08T22:21:45+05:30September 8th, 2019|Categories: Programming|Tags: |

Const Qualifier in C

const qualifier in C/C++ can be applied to the declaration of any variable to specify that its value will not be changed.  const keyword applies to whatever is immediately to its left. If there is nothing to its left, it applies to whatever is immediately to its right. Pointer to [...]

By |2020-09-03T14:38:14+05:30March 28th, 2019|Categories: Programming|Tags: |

Normal function vs Inline function in C

A function is a block of code that performs a specific task. It improves the readability of the code. Syntax Syntax of normal function and inline function is same except that inline function has the keyword inline in its definition. Below is the example showing both function types. #include <iostream> [...]

By |2020-09-04T16:03:58+05:30May 25th, 2018|Categories: Programming|Tags: |

typedef versus #define in C

typedef is used to give data type a new name. #define is a C directive which is used to define alias. // BYTE can be used in place of unsifned char typedef unsigned char BYTE; // HYD is replaced by "Hyderabad" #define HYD "Hyderabad" typedef interpretation is performed by the [...]

By |2018-09-29T17:02:43+05:30October 14th, 2017|Categories: Programming|Tags: |
Go to Top