Check two points are equal.

How to check two points are equal using C++ STL?
Input :
0, 0
0, 0

Output :

Why you want this question from STL? It can simply be perform by if-else condition.

1 Like

Suppose you have two points as pair<int,int> .

p1,p2 are the two points,then you write


Remember to enclose (p1==p2)?“YES”:“NO” in parentheses as conditional operator have least precedence.

So cout<<((p1==p2)?“YES”:“NO”); can get your job done.

Hope it helps…

1 Like

Vector V[0] represent a pair inside Vector, so V[0].first represent the first element and V[0].second represent the second element of V[0]. Same case are applying on V[1]. So i compare condition you are just comparing both these value of vector- (V[0], V[1]) by simply if condition.

As pointed out by others, you don’t need to use STL here. Normal comparison operation will do.

But since you ask specifically for using C++ STL, refer to

Declare an object of equal_to of appropriate type (pair< int, int > here). Let it be f. Just call f(V[0], V[1]).

Here is an example -

1 Like

I tried to implement this code :

But here No STL are used. Only if else are used

But how???