CPP

C++ Auto

The auto keyword is a C++11 feature.  Note:- Use “g++ -std=c++0x filename.cpp” to enable this feature. The compiler is able to determine the type of a variable from its initialization. With the advent of template types and template metaprogramming techniques, the type of something, particularly the well-defined return value of a function, may not be …

C++ Auto Read More »

C++ constexpr

C++ 11 introduces constexpr. Note:- Use “g++ -std=c++0x filename.cpp” to enable this feature. constexpr allows computations to take place at compile time rather than at run time. This gives performance benefits. constexpr allows the user to guarantee that a function or object constructor is a compile-time constant. constexpr could be specified on a function with …

C++ constexpr Read More »

C++ decltype

C++ decltype The decltype operator is a C++11 feature.  Note:- Use “g++ -std=c++0x filename.cpp” to enable this feature. The decltype operator allows to querying the type of an expression. In decltype(e) if e is an identifier, expression or class member decltype(e) is defined as type of e. In decltype(e) if e is a function call …

C++ decltype Read More »

CDT Plugin for Eclipse

I have recently started using C++ development using eclipse and found it interesting and thought of sharing the setup details here. Main motive for me to use Eclipse CDT (C++ Development Tooling) is that I wanted a uniform IDE for both my Java and C++ needs. Also for my work I keep switching operating systems …

CDT Plugin for Eclipse Read More »

C++ Bit Fields

What are bit-fields? Bit fields provide a mechanism to optimize memory usage by allowing to specify the exact number of bits required to store data. Quite useful in embedded programming like mobile phones where memory is limited. The declaration of bit field members follow the syntax “variable name : number of bits”. Unnamed bit fields …

C++ Bit Fields Read More »

C++ Overriding

What is overriding in C++? Redefining a base class function in the derived class to have our own implementation is referred as overriding. Often confused with overloading which refers to using the same function name but with a different signature. However in overriding the function signature is the same. Demonstrate the usage of overriding #include …

C++ Overriding Read More »

C++ Copy Assignment Operator

What is copy assignment operator in C++? The copy assignment operator allows to assign objects of same class to each other by overloading ‘=’ operator. The compiler automatically generates this member function if is not defined explicitly. The generated copy assignment funcion does a bit wise copy or in other words shallow copy. If our …

C++ Copy Assignment Operator Read More »

C++ Default Arguments

What are default arguments in C++? Default argument is a value given in the function declaration. The compiler automatically inserts this if a value is not provided during the function call. Default arguments are similar to function overloading in the sense that both features allow to use a single function name in different scenarios. The …

C++ Default Arguments Read More »

C++ STL Reference

Good reference to Standard Template Library (STL):- About the Standard Template Library Iterators C++ Algorithms C++ Vectors C++ Double-Ended Queues C++ Lists C++ Priority Queues C++ Queues C++ Stacks C++ Sets C++ Multisets C++ Maps C++ Multimaps C++ Bitsets

About STL

What is STL? STL refers to the Standard Template Library of C++. STL is a generic library that provides collections classes for managing data and algorithms that operate on them. STL avoids the need to implement our own data structures and algorithms like linked lists, binary trees etc and they are directly available for use. …

About STL Read More »