Shell Scripting Tutorial: Shell Script Conditional Statements
C++ 11 feature: Initializer Lists and Static Assertions
In this chapter we shall study 2 new concepts of C++. 1. Initializer List 2. Static Assertions 1. Initializer List It is used to initialize data members of a class or to create a container of elements. It can be created using braced list syntax, for example {1, 2, 3}. It will create a sequence […]
C++ 11 feature: Forwarding References
Forwarding Reference is a new feature in C++11. They are also called as Universal References. It means, it will binds to both lvalues and rvalues. We will see in example further below. Forwarding reference uses the syntax “T&&” or “auto&&”. What is the difference between rvalue reference and forward reference ? rvalue reference looks like […]
C++ 11 feature: Parameter Pack and Variadic Templates
Parameter Pack: Parameter pack is the new feature in C++11. “…” is the syntax to create a parameter pack or to expand one . Parameter pack is used to pack multiple parameters into single parameter. This can be done by placing ellipsis “…” to the left of the parameter name. Below example shows how to […]
C++ 11 and 14 feature lambda expression
Lambda function is used for functional programming. In this chapter we shall learn about lambda functions. Lambda expressions are used to define an anonymous function object or closure. In C++ a simple lambda can be defined as below: [] () {} Here [] is the capture list () is the argument list {} is the […]
C++ 11 feature: reinterpret_cast
“reinterpret_cast” has been introduced in C++ 11. This cast should be carefully used. * reinterpret_cast is used to convert one pointer to another pointer of any other type. * It will not check if the pointer and the data pointed by the pointer are same or not. Syntax of reinterpret_cast cast: data_type *var_name = reinterpret_cast […]
C++ 11 feature: dynamic_cast with RTTI
“dynamic_cast” is new concept in C++ 11. dynamic_cast is used at runtime to check the correctness of down casting. As it checks the correctness at runtime, it is slower than “static_cast”. “dynamic_cast” is used in handling polymorphism. “dynamic_cast” will return the object if the cast is correct else it will return NULL. Note: There should […]
C++ 11 feature: const_cast
“const_cast” is new concept in C++ 11. const_cast is used to remove the constantness from references and pointers. I agree we used const pointer so to avoid un-necessary data modification. But there will be some instances where you need to modify the const data. In such situation “const_cast” will be useful. Syntax of const_cast cast: […]
C++ 11 feature: static_cast
Casting is a new feature in C++. Below are the different types of csating available: 1. Static Cast 2. Dynamic Cast 3. Const Cast 4. Reinterpret Cast static_cast in smart pointers: Points on Static cast: 1. static_cast is used for compile time checking. 2. static_cast can easily be searched in C++, thus making easily readable […]
C++ 11 feature: typealias
“typealias” is a new feature introduced in C++ 11. It is the replacement of typedef. “using” is the keyword used in typealias. typealias is used to give an alternate name for already exsisting data type. We shall see how to define using typealias and also using typedef. If you want to defined “unsigned long” to […]