Tag: C
C++ std::vector example and why should I use std::vector?
Vector is a template based container that behaves just like a Dynamic Array. It can expands its memory at run time and always store elements in contiguous memory location just like Array. Advertisements We can store any type of element in vector by specifying the type as template argument. [showads ad=inside_post] Frequently Asked: Be careful …
C++ std::vector example and why should I use std::vector?Read More
How to use vector efficiently in C++?
We can use vector efficiently by taking care of following points, 1.) Vector will be more efficient if elements are inserted or removed from the back-end only. Advertisements As, vector internally stores all the elements in consecutive memory location. Therefore, if an element is added in middle, then vector right shifts all the right side …
c++ std::vector and Iterator Invalidation example
In this article we will discuss the iterator invalidation with respect to std::vector in C++. What is Iterator Invalidation? An Iterator becomes invalidate when the container it points to changes its shape internally i.e. move elements from one location to another and the initial iterator still points to old invalid location. Advertisements Iterator invalidation in …
Designing Callbacks in C++ – Part 1: Function Pointers
In this article we will discuss what is a callback and what types of callbacks we can have in C++ and how to Design Callbacks as function pointers. Now what is a callback? Advertisements Callback is a function that we pass to another APIs as argument while calling them. Now these APIs are expected to …
Designing Callbacks in C++ – Part 1: Function PointersRead More
Designing Callbacks in C++ – Part 2: Function Objects & Functors
In this article we will discuss, what is a Function Object, why do we need function objects and how to use function objects as Callbacks. What is a Function Objects: Advertisements A Function Object / Functor is a kind of Callback with State. In a Programmer’s terminology, Frequently Asked: Designing Callbacks in C++ – Part …
Designing Callbacks in C++ – Part 2: Function Objects & FunctorsRead More
What is a Memory Leak in C++ ?
In this article we will discuss what is Memory Leak C++ and why its harmful for applications. Memory Leak Advertisements Memory leak in is a kind of Bug that kills your application slowly by first making it slow and then eventually crashing it. How Does Memory Leak happens: Frequently Asked: What is a Memory Leak …
C++ std::list Tutorial, Example and Usage Details
In this article we will discuss std::list usage details. What is std::list ? std::list is sequential STL container that is internally implemented as doubly linked list. i.e. every element in the list is stored at a seperate memory location i.e. called node and it also contains a pointer to the previous and next node. Advertisements …
How to trim strings in C++ using Boost String Algorithm Library
In this tutorial we will discuss how to use trim algorithms from C++ Boost String Algorithm Library. Let’s learn them step by step, Boost String algorithm library provides different algorithms for string trimmings. Let’s first discuss the simple one i.e, What if we want to trim the string of white spaces from left side or …
How to trim strings in C++ using Boost String Algorithm LibraryRead More
Creating a Matrix using 2D vector in C++ – Vector of Vectors
In this article will discuss how to create 2D Matrix using vector of vectors in c++. Requirement Advertisements Represent a 2D Matrix using vector in C++ i.e. 1 , 1 , 1 , 1 1 , 1 , 1 , 1 1 , 1 , 1 , 1 1 , 1 , 1 , 1 …
Creating a Matrix using 2D vector in C++ – Vector of VectorsRead More
Compiling C++ with Debug Symbols – gdb debugger Tutorial & Examples
In this article we will discuss how to build a C++ / C code in debug mode and how to start the debugging using gdb. Compile Code with Debug Symbols To debug a C or C++ application with gdb, it should be built in debug mode. So that debug symbols can be loaded and used …
Compiling C++ with Debug Symbols – gdb debugger Tutorial & ExamplesRead More