- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7346 Articles for C++
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
22K+ Views
The following are the differences between vector and array −Vector is a sequential container to store elements and not index based.Array stores a fixed-size sequential collection of elements of the same type and it is index based.Vector is dynamic in nature so, size increases with insertion of elements.As array is fixed size, once initialized can’t be resized.Vector occupies more memory.Array is memory efficient data structure.Vector takes more time in accessing elements.Array access elements in constant time irrespective of their location as elements are arranged in a contiguous memory allocation.Vectors and arrays can be declared with the following syntax −Vector declaration:vectorarray ... Read More
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
5K+ Views
In this section we will see what are the differences between namespace and class in C++. The namespace and classes are two different concepts. Classes are datatypes. Classes are basically extended version of structures. Classes can contain data members and functions as members, but namespaces can contain variables and functions by grouping them into one.The namespaces cannot be created as objects. This concept is used as additional information to differentiate similar functions, classes, variables etc. Variables, functions with same name can be placed in different namespaces.Now let us point out some important differences of namespaces and classes.The namespaces are used ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
398 Views
We shall develop a C++ program to implement Gift Wrapping Algorithm in two dimensions. The Gift Wrapping Algorithm is an algorithm for computing the convex hull of a given set of points.AlgorithmBegin function convexHull() to find convex hull of a set of n points: There must be at least three points. Initialize the result. Find the leftmost point. Starting from leftmost point, keep moving counterclockwise until reach the start point again. Print the result. EndExample Code Live Demo#include using namespace std; #define INF 10000 struct P { int x; int y; ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
206 Views
We shall consider a C++ Program to check if a point d lies inside or outside a circle defined by points a, b, c in a plane by using equations = (x-xt)^2 + (y-yt)^2 – r*rWhere, For any point t (xt, yt) on the plane, its position with respect to the circle defined by 3 points (x1, y1), (x2, y2), (x3, y3).for s < 0, t lies inside the circle.For s >0, t lies outside the circle.For s = 0, t lies on the circle.AlgorithmBegin Take the points at input. Declare constant L = 0 and H = ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
168 Views
Here is a C++ program to use above below primitive to test whether two lines intersect. It can be used to test whether a line intersects a line segment. It does if and only if one endpoint of the segment is to the left of the line and the other is to the right.AlgorithmBegin For generating equation of the first line, generate random numbers for coefficient of x and y by using rand at every time of compilation. For generating equation of the second line, generate random numbers for coefficient of x and y by using rand at ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
85 Views
Here is a C++ program to find the area of polygon using slicker algorithm that avoids Triangulation to find area of a polygon.It assumes the usual mathematical convention that positive y points upwards. In computer systems where positive y is downward, the easiest thing to do is to list the vertices counter-clockwise using the “positive y down” coordinates. Two effects then canceled out to produce a positive area.Functions and pseudocodeAlgorithmBegin function Area() is used to calculate area of a polygon take the polygon p as argument. for i = 0 to p.n-1 initialize j = ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
373 Views
This is a C++ program to apply Above-Below-on Test to find the position of a point with respect to a Line. For any point t (xt, yt) on the plane, its position with respect to the line L connecting m and n is found by calculating the scalar s −Y = A xt + B yt + CIf Y< 0, t lies in the clockwise halfplane of L; if Y>0, t lies on the counter-clockwise halfplane; if Y= 0, t lies on L.AlgorithmBegin Take the points as input. For generating equation of the line, generate random numbers for ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
223 Views
When we write programs to do computation at compile time using a template, that is called Template Metaprogramming.Example Code#include using namespace std; templatestruct power { enum { value = 4*power::value }; }; templatestruct power { enum { value = 1 }; }; int main() { cout
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
230 Views
Variadic function templates in C++ is a function which can take a multiple number of arguments.Syntaxtemplate(typename arg, typename... args) return_type function_name(arg var1, args... var2)Example Code Live Demo#include using namespace std; void show() //base case. { cout
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
124 Views
In C++ methods are non-virtual by default. They can be made virtual function by using a virtual keyword.Example Code#include using namespace std; class B { public: void s() //non virtual by default. Use virtual before the function to print “In Derived” { cout