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 659 of 719
5K+ Views
In C++ program, struct is a keyword used to define a structure, while typedef is a keyword that is used to create an alias for a data type. In this article, we will discuss the difference between struct and typedef struct in C++. Struct in C++ Struct is a keyword used to define a structure in C++. A structure is a user-defined data type that groups related variables of different data types into a single unit. Struct is same as a class, but the members of a struct are public by default. The syntax for defining a struct is ... Read More
691 Views
static_cast − This is used for the normal/ordinary type conversion. This is also the cast responsible for implicit type coersion and can also be called explicitly. You should use it in cases like converting float to int, char to int, etc.dynamic_cast − This cast is used for handling polymorphism. You only need to use it when you're casting to a derived class. This is exclusively to be used in inheritance when you cast from base class to derived class.Regular Cast − This is the most powerful cast available in C++ as it combines const_cast, static_cast and reinterpret_cast. but it's also ... Read More
1K+ Views
The argc stands for argument count and argv stands for argument values. These are variables passed to main function when it starts executing. When we run a program we can give arguments to that program like:$ ./a.out helloHere hello is an argument to the executable. This can be accessed in your program.Example Code#include using namespace std; int main(int argc, char** argv) { cout
1K+ Views
In C++, segmentation fault is a runtime error that occur when your program attempts to access an area of memory that it is not allowed to access. In other words, segmentation fault occur when your program tries to access memory that is beyond the limits that the operating system allocated for your program. These errors are type of access violation that can lead to crashing of program. Segmentation fault occur often with beginner programmers due to the lack of understanding of system level concepts like pointer. In this article, we will explain all the concepts related to segmentation fault, including ... Read More
9K+ Views
The C++ functions can receive objects in multiple ways, depending upon how you want the function to interact with the object. You can either define functions that can modify the original objects or define functions that will make a copy of original object and modify the copy without affecting the original object. In this article, we will explain all the ways to pass an object a C++ function. Pass Objects to Function in C++ Here is the list of all the ways to pass an object to a function in c++ program, which we will be discussing ... Read More
392 Views
The only safe way is to check for overflow before it occurs. There are some hacky ways of checking for integer overflow though. So if you're aiming for detecting overflow in unsigned int addition, you can check if the result is actually lesser than either values added. So for example, Example Codeunsigned int x, y; unsigned int value = x + y; bool overflow = value < x; // Alternatively "value < y" should also workThis is because if x and y are both unsigned ints, if added and they overflow, their values can't be greater than either of them ... Read More
1K+ Views
A subsequence is a sequence that can be derived from another sequence by deleting some elements and without changing the order of elements in sequence. For example, the sequences [3, 10], [3, 2, 20] and [3, 10, 20] are some of the subsequences of [3, 10, 2, 1, 20]. Longest Increasing Subsequence(LIS) is the longest of all the subsequences that are having elements in increasing order. In this article, we will learn how to write a C++ program to find the length of longest increasing subsequence for a given sequence. In other words, we are provided with a sequence ... Read More
1K+ Views
A convex hull is the smallest convex polygon with maximum area and minimum perimeter that encloses all the given points in a 2D plane. In this article, we will learn how to write C++ program to implement Jarvis March Algorithm to find a convex hull. The objective of this problem is to take a set of x and y coordinates of a 2d plane as input, and display coordinate point from the set which are part of convex hull. // Input Set of points: {0, 0}, {1, 1}, {2, 2}, {2, 0}, {1, 2}, {0, 2} // Output ... Read More
4K+ Views
A convex hull is the smallest convex polygon with maximum area and minimum perimeter that encloses all the given points in a 2D plane. In this article, we will learn how to write C++ program to implement Graham Scan Algorithm to find convex hull. The objective of this problem is to take a set of x and y coordinates of a 2d plane as input, and display coordinate point from the set which are part of convex hull. // Input Set of points: {0, 0}, {1, 1}, {2, 2}, {2, 0}, {1, 2}, {0, 2} // Output Boundary ... Read More
15K+ Views
The adjacency matrix of a graph is a square matrix of size V x V, that represent a finite graph data structure using a 2D array, where V is number of edges of the graph. The each non zero elements in the matrix represent an edges of the graph. For example, if the graph has some edges from i to j vertices, then in the adjacency matrix at i th row and j th column it will be 1 (or some non-zero value for weighted graph), otherwise that value will be 0. In this article, we will learn how to ... Read More