Page 1 of 1

Write a class template, Pair, that implements ordered pairs of any type. Your class template should include constructors

Posted: Sat May 14, 2022 7:04 pm
by answerhappygod
Write
a class template, Pair,
that implements ordered pairs of any type. Your class template
should include constructors and member functions so that when it is
combined with the following main, compiled, and run, the
output shown will be generated.
int
main()
Output:
{
Pair<int>
iP(4,5);
4
Pair<float>
fP(6.73,8.92);
6.73
Pair<char>
cP('d','g');
d
cout << iP.first() <<
endl;
5
cout << fP.first() <<
endl;
8.92
cout << cP.first() <<
endl;
g
cout << iP.second() <<
endl;
(4 , 5)
cout << fP.second() <<
endl;
(6.73 , 8.92)
cout << cP.second() <<
endl;
(d , g)
iP.display();
fP.display();
cP.display();
return 0;
}