+ 3
What are ideal situation when we use pair<> in c++. Can we compare two different objects using pair<obj1,obj2> p ; like this ..
5 Respuestas
+ 7
This class couples together a pair of values, which may be of different types (T1 and T2). The individual values can be accessed through its public members first and second.
T1 Type of member first, aliased as first_type.
T2 Type of member second, aliased as second_type.
LIKE THAT:
#include <iostream>
using namespace std;
int main ()
{
pair<int, int> k = make_pair(1,2);
}
+ 5
I was trying to compare two objects of class, is it possible ?
+ 5
it is better i think to use:
bool operator==(const name1& l1, const name2& l2);
+ 5
Good idea ! thanks man
0
you are welcome