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;
}
Write a class template, Pair, that implements ordered pairs of any type. Your class template should include constructors
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Write a class template, Pair, that implements ordered pairs of any type. Your class template should include constructors
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!