CPP STL Tutorial: std::vector and it’s operations.
In this chapter we shall learn about: 1. vector introduction. 2. vector declaration. 3. Multidimensional std::vector 4. Passing std::vector to function 5. vector member function to iterate over elements. 6. vector member function to check the capacity. 7. vector member function to access the elements. 8. vector member function to modify the elements. 9. How […]
CPP STL Tutorial : std::array and it’s operations
Note: std::array feature is only available in C++11 and above. In this chapter we shall learn about below topics:, 1. array introduction. 2. array declaration. 3. Multidimensional std::array 4. Passing std::array to function 5. array member function to iterate over elements. 6. array member function to check the capacity. 7. array member function to access […]
Cpp STL Tutorial: STL Introduction
C++ Structured Template Library. As the name suggests, it is a library, which comes by default with you install any C++ compiler. C++ STL has below 3 important components: 1. C++ Containers: Used to store the data in an organized way. 2. C++ Algorithms: Used to manipulate the data. 3. C++ Iterators: Used to access […]
Cpp Tutorial: Cpp memory model: New and Delete operators in Cpp
In C++ there is a concept of Dynamic Memory Allocation. The concept of allocating memory during run time is called as Dynamic Memory Allocation. Here the memory allocated in Heap segment. You can use C style “malloc ()” and “free ()” functions, but C++ provides “new” and “delete” operators. As “new” will allocate the memory […]
Cpp Tutorial: User defined exception in Cpp
In the previous chapter we saw how to work with exception. In this chapter we shall see how to define our own exeption. User defined exception might be useful in the case which are not pre defined in C++. In such cases we should define our own exception. We can create our own exceptions by […]
Cpp Tutorial: Cpp Constructor Member Initializer List tutorial with different use cases
In this chapter we shall learn about below topics: 1. what is constructor initializer list? 2. Constructor initializer list using “()” 3. Constructor Initializer list using “{}” 4. User cases of Constructor Initializer List. 1. Initialization of non-static const data members 2. For initialization of reference members 3. For initialization of base class members 4. […]
Cpp Tutorial: Exception Handling in C++
An exception is an error condition that occurs during run time. Generally without exception handling, the program will crash when there is an exception. We place the code where the exception might occur and we handle that exception without crashing the program. C++ provides 3 types of exception handling keywords: try, catch, throw. try: We […]
Cpp Tutorial: Structure Padding and Bitfields in C++
In this chapter we shall look at below topics: What will be the size of structure in below example? Now why we add extra bytes? How to avoid structure padding? Structure Packing: Bitfields in C++ Before we look at Structure Padding and Structure Packing, let’s see an example below: What will be the size of […]
Cpp Tutorial: C++ structure padding and packing
In this tutorial we shall learn about structure padding. We shall learn below topics: What is structure padding? How to avoid structure padding? How to avoid structure padding using a macro? 1. What is structure padding? Padding is a concept to add more bytes to structure or class, so that the accessing will be easier. […]
Cpp Tutorial: C++ Structure
Till now we have seen everything about classes. Now we shall see in-depth on C++ Structures. In this chapter we shall learn about below topics in C++: Structure Introduction: How to define a structure? How to create structure variable? Example for a structure with constructor, member function and data member. Difference between C structures and […]