Cpp Tutorial: Different types of Constructors in C++
In this tutorial we shall learn about below different types of Constructors: 1. Default Constructor 2. Parameterized constructors 3. Overloading constructors 4. Constructor with default arguments 1. Default constructor: 1. A constructor that does not take any arguments is called as default constructor. 2. When an object is created default constructor is called. 3. Default […]
Cpp Tutorial: Introduction to Constructor and Destructor in C++
In this chapter we shall look at below topics 1. Introduction 2. Constructor and its properties 3. Destructor and its properties 1. Introduction In the previous chapter we have seen, to initialize the data members we used a helper method like “setters” and “getters” after creating an object. But with the help of constructors we […]
Cpp Tutorial: Different types of Classes in C++
In this chapter we shall look at different types of classes available in C++ 1. Global Classes in C++ 2. Local Classes in C++ 3. Nested Classes in C++ 4. Anonymous classes in C++ 1. Global Classes in C++ 1. Class defined outside of all the functions is called as Global Class. 2. The objects […]
Cpp Tutorial: Scope resolution operator in C++
In this tutorial we shall see different uses of Scope Resolution Operator 1. To access a global variable. 2. In case of multiple inheritance. 3. To Access class static variables. 4. To access static member function 5. To define a function outside the class. 1. To access a global variable. #include <iostream> using namespace std; […]
Cpp Tutorial: Constant member functions and Overloading Member Functions, Mutable in C++
In this tutorial we are going to study about 1. Constant Member Functions 2. Mutable Keyword 3. Overloading Member Functions 1. Constant Member Functions in C++ Below are few points on Constant Member Functions 1. “const” is the keyword to declare a constant member function. 2. Once the member function is declared as constant, it […]
Cpp Tutorial: Static data members, static member functions and Static objects in C++
In this chapter we shall study about: 1. Static data members 2. Static member functions 3. Static Objects 1. Static data members Below are the properties of static data members: 1. “static” is the keyword used to create static data members. 2. We want to create static data members, when we want only one copy […]
Cpp Tutorial: Friend function and friend class in C++
In this chapter we shall learn about below topics: 1. Friend Introduction. 2. Friend Function 3. Example 1: Program to add 2 using a friend function. 4. Example 2: 5. Friend Class 1. Friend Function Introduction We know that C++ is a Object Oriented Programming language. It supports data hiding. i.e making data members private […]
Cpp Tutorial: Cpp this pointer in C++
In this chapter we shall learn about below topics: 1. What is this pointer in C++? 2. Where is “this” pointer is accessible? Usage of “this” pointer: 1. Usage 1 2. Usage 2 3. Usage 3 What is this pointer in C++? “this” pointer holds the address of the current object that is being called. […]
Cpp Tutorial: C++ Size of an object in C++
1. Where are member functions stored in C++ 2. Introduction to size of object. 3. Size of object without structure padding 4. Size of object with structure padding 5. Size of object with static data members. 6. Size of object with virtual function 7. Size of object with Inheritance 8. Size of Empty Class in […]
Cpp Tutorial: C++ Access specifiers or Modifiers
Access specifiers are used to implement most important concept in C++. i.e Data Hiding. We shall discuss how access specifiers will help in Data Hiding at the end of the chapter. It is usual practice that we make Data members as private and expose them to the programmer by using public getters and setters. There […]