How to Fix error: expected primary-expression before ‘)’ token (C) in C++

The “error: expected primary-expression before ‘)’ token” occurs in C++ at a compile-time error message that suggests that there is a problem with the syntax of your code, specifically that a primary expression (a variable, constant, or expression that evaluates to a value) is expected before a closing parenthesis token (‘)’). To fix the “error: … Read more

How to Fix expression must have a constant value in C++ Length

The error “expression must have a constant value” in C++ length occurs when you try to use a non-constant value in a context that requires a constant expression. To fix the “expression must have a constant value” in C++ length error, declare it constant with the const keyword. You can also use the constexpr specifier introduced … Read more

What is unordered_map in C++

Introduction to unordered_map in C++ C++ unordered_map containers are faster than typical map containers. This is attributed to the unordered map being implemented using hash tables. Definition and purpose C++ unordered_map is a  built-in container that stores elements in key-value pairs. The values in unordered_map containers are not internally defined in any specific fashion. The … Read more

Deque in C++: The Complete Guide

Deque stands for a double-ended queue. It is pronounced as “deck”. It is containers that have dynamic sizes and can be expanded or contracted on both ends, i.e., both ends are operational in this deque. Vectors also have contiguous storage allocation, but memory is generally dynamically allocated in the case of the deque. Deque in … Read more

C++ List: How to Add, Assign, Delete List in C++

Introduction to C++ List Definition and Overview C++ List is a built-in sequence container with STL(Standard Template Library) that allows non-contiguous memory allocation. It is part of the Standard Template Library (STL) and is defined in the header file <list>. The list uses non-contiguous memory allocation, so traversal is slower than vector in C++. The list … Read more

C++ Multiset: The Complete Guide

Multisets are containers very similar to sets; the main difference in multisets is that they can have multiple elements with the same values, unlike in sets. Multisets containers store the item in a particular specific order. In multisets, we can erase more than 1 element by giving start and end iterators. Multiset in C++ A … Read more

C++ Vector: The Complete Guide

C++ Vector is a template class that perfectly replaces suitable old C-style arrays. It allows the same natural syntax used with plain arrays. In addition, it offers a series of services that free the C++ programmer from taking care of the allocated memory and consistently operating on the contained objects. C++ STL C++ STL (Standard … Read more

C++ Set: Standard Template Library(STL)

C++ set containers are slower than the unordered_sets containers when accessing individual elements by their key. Still, the main advantage of sets is that they allow the direct iteration of the subsets based on their order of items in the container. Set in C++ C++ set is a built-in associative container that contains unique objects because … Read more

Pair in C++: The Complete Guide

Pair is heterogeneous, i.e., it allows the storage of a variable of different data types. Pair in C++ can be assigned, copied, and compared. C++ Pair C++ Pair is a built-in container in the STL library consisting of two data elements or objects. The pair container is a simple container defined in <utility> header consisting … Read more

C++ Iterator: The Complete Guide

C++ Iterators are used to point at the memory addresses of STL containers. They are primarily used in the sequence of numbers, characters etc.used in C++ STL. It is like a pointer that points to an element of a container class (e.g., vector, list, map, etc.).  Operator * : Returns the element of the current position. … Read more

C++ Pointer: The Complete Guide

To understand the pointer, let’s review the “regular” variables first. If you’re familiar with the programming language without pointers like JavaScript, this is what you think when you hear “variable”. C++ Pointer C++ pointer is a variable whose value is the address of another variable. Pointers are a symbolic representation of addresses. Pointers enable programs … Read more