Cpp Tutorial: Class template with Overloaded Operators and template Inheritance in C++
In this chapter we shall see below topics: 1. Class template with overloaded operators 2. Template Inheritance 1. Class template with overloaded operators It is possible to use operator overloading with class template. Below example will show how to achieve the same. Example: #include <iostream> // for more tutorials visit www.ProDeveloperTutorial.com using namespace std; template […]
C++ Tutorial: Class Template in Cpp
In this tutorial we shall see below topics. 1. Class Template 2. Class Template with more parameters 1. Class Template Syntax for class Template template <class T> class <class_name> { }; In the below example we shall see a program without using class template and with using class template. Example without using class template. #include […]
Cpp Tutorial: Function Template in C++
In this tutorial we shall learn about below topics Introduction to Function template Syntax for function template: Example for simple function template Function Template with more arguments Overloading function template Recursion with function template 1. Introduction to Function template The function defined outside a class is called as normal functions. Generally normal function will work […]
Cpp Tutorial: Introduction to template programming in C++
In this tutorial we shall learn about below points: 1. Introduction to template programming. 1. Templates are very important topic in C++. With the help of templates we can write functions that will work with any type of data types. 2. A function that works with any data type is called as generic function. 3. […]
Cpp Tutorial: Different types of Member Functions in C++
Below are different types of member functions available in C++ 1. Simple member functions 2. Static member functions 3. Const member functions 4. Inline member functions 5. Friend functions 1. Simple member functions: The function defined inside a class without any kind of keyword delared are called as simple member functions. Example: #include <iostream> // […]
Cpp Tutorial: Upcasting and downcasting in C++
Upcasting: It is the process of converting derived-class reference or pointer to the base class. Downcasting: It is the process of converting base-class reference or pointer to the derived class. Upcasting: Here the derived class pointer is converted to base class. This is allowed in inheritance. There is no need of explicit typecasting. There is […]
Cpp Tutorial: Namespace in C++
In this chapter we shall learn about below topics: 1. Introduction 2. Declaring namespaces 3. Accessing namespace using “using” directive 4. The global namespace 5. The std namespace 6. Nested namespaces 7. Inline namespaces (C++ 11) 8. Namespace aliases 9. Anonymous or unnamed namespaces 10. Discontiguous Namespace in C++ 1. Introduction Namespace are used to […]
Cpp Tutorial: Working of Vtable and _vptr in C++
In this chapter we shall learn about vtable and _vptr in C++. vtable and _vptr is used to support runtime polymorphism or dynamic binding. Few Points about Vtable: vtable is also called as virtual table. vtable is used as lookup table during runtime. vtable gives the information about the function binding. All the class that […]
Cpp Tutorial: Order of Constructor and Destructor Call in inheritance in C++
In this chapter we shall see the order of Constructor and Destructor in inheritance 1. Order of Constructor and destructor call for simple inheritance 2. Order of Constructor and destructor call for multiple inheritance 1. Order of Constructor and destructor call for simple inheritance In this topic we shall see how the constructor and destructor […]
Cpp Tutorial: Virtual destructor and Pure virtual destructor in C++
Need for virtual destructor. When you delete a derived class object by using a base class pointer, the destructor call will be an undefined behavior. For example: In the below code, we are creating an object of derived class and assigning to base class pointer. Now when use “delete” operator, check the output: #include <iostream> […]