Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Articles - Page 688 of 719
15K+ Views
A circular singly linked list is a type of data structure that is made up of nodes that are created using self-referential structures. Each node contains two components, namely the data element and the reference to the next node in the list. Only the reference to the head node is required to access the whole linked list. The last node of the list points to the head node, which makes it a circular linked list. Let's see a diagram of circular linked list. Circular linked lists are mainly useful for scheduling tasks and managing playlists, enabling smooth navigation. ... Read More
91K+ Views
A singly linked list is a type of data structure where each item (called a node) has two parts: the data and a link to the next node in the list. You start from the first node (called the head) and keep going until the link is empty (NULL). For example, let's understand with this list of numbers: 9 -> 2 -> 7 -> 1 -> 3 -> NULL In this case, the node containing 9 is the head, and the node containing 3 is the last node (its next pointer is NULL). In this article, we will show ... Read More
30K+ Views
In C++, arranging the elements in increasing or decreasing order is called as Sorting. we usually use the sort() function from the STL (Standard Template Library). A sorted array is an array whose each of the elements are sorted in some order such as numerical, alphabetical etc. There are many algorithms to sort a numerical array like bubble sort, insertion sort, selection sort, merge sort, quick sort, heap sort, etc. The selection sort is a sorting method that yields a sorted array. It does so by repeatedly finding the smallest element in the array and interchanging it with the element ... Read More
19K+ Views
The binary search algorithm works as per the divide-and-conquer principle, as it keeps dividing the array in half before searching. To search for an element in an array using binary search, it should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left or right sub-array or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element using the binary search ... Read More
10K+ Views
Constructors are functions of a class that are executed when new objects of the class are created. The constructors have the same name as the class and no return type, not even void. They are primarily useful for providing initial values for variables of the class.The two main types of constructors are default constructors and parameterized constructors. Details about these are given as follows.Default ConstructorsDefault constructors do not take any parameters. If a default constructor is not provided by the programmer explicitly, then the compiler provides a implicit default constructor. In that case, the default values of the variables are ... Read More
29K+ Views
A nested class is a class that is declared in another class. The nested class is also a member variable of the enclosing class and has the same access rights as the other members. However, the member functions of the enclosing class have no special access to the members of a nested class. Syntax Here is the basic syntax defining and using nested classes in C++. class OuterClass { // Members of the outer classpublic: // Nested class definition class InnerClass { // Members of the inner class };}; Accessing Nested Classes To access a nested class from outside ... Read More
3K+ Views
A class declared inside a function is known as a local class in C++ as it is local to that function, where its scope is limited to that function. Syntax Here the syntax for a local class is given as follows. #include using namespace std; void func() { class LocalClass { }; } int main() { return 0; } In the above syntax, func() is a function, and class LocalClass is defined inside the function. So, it is known as a local class. A local class name can only be used in its function and not outside it. Also, the ... Read More
7K+ Views
strdup() The function strdup() is used to duplicate a string. It returns a pointer to a null-terminated byte string. Syntax Here is the syntax of strdup() in C language, char *strdup(const char *string); Example Here is an example of strdup() in C language. #include #include int main() { char *str = "Helloworld"; char *result; result = strdup(str); printf("The string : %s", result); return 0; } Output The string : Helloworld strndup() The function strndup works similarly to the function strndup(). This function duplicates the string at most size bytes i.e. the given size in the function. It also returns ... Read More
294 Views
The function strcoll() is used to compare two strings using locale - specific collating sequence.It returns −zero, when both strings are same, greater than zero value when first string is greater than otherless than zero value, when first string is less than other.Here is the syntax of strcoll() in C language, int strcoll(const char *first_string, const char *second_string);Here is an example of strcoll() in C language, Example Live Demo#include #include int main () { const char s1[] = "Helloworld"; const char s2[] = "Blank"; char *result; result = strcoll(s1, s2); if(result > 0) ... Read More
770 Views
atol() FunctionThe function atol() converts string into a long integer. It returns zero, when no conversion is performed. It returns the converted long int value.Here is the syntax of atol in C++ language,long int atol(const char *string)Here is an example of atol() in C++ language,Example Live Demo#include using namespace std; int main() { long int a; char str[20] = "538756"; a = atol(str); cout