| | |
Help with Explicit parameter polymorhphism
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 16
Reputation:
Solved Threads: 0
So explicit parametric polymorphism need not be restricted to a single type parameter. In other words I can write this in C++
Can someone help me write a funciton "makePair" that takes two paramters of different types and returns a Pair containing its two values?
Hope someone can help
C++ Syntax (Toggle Plain Text)
template <typename First, typename Second> struct Pair { First f; Second s; };
Can someone help me write a funciton "makePair" that takes two paramters of different types and returns a Pair containing its two values?
Hope someone can help
•
•
Join Date: Dec 2006
Posts: 1,089
Reputation:
Solved Threads: 164
have a look at the standard header <utility>. it defines std::pair and std::make_pair.
C++ Syntax (Toggle Plain Text)
template <typename First, typename Second> struct Pair { First f; Second s; Pair( const First& ff, const Second& ss ) : f(ff), s(ss) {} // etc }; template <typename First, typename Second> inline Pair<First,Second> makePair( const First& f, const Second& s ) { return Pair<First,Second>( f, s ) ; }
![]() |
Other Threads in the C++ Forum
- Previous Thread: counting a string array
- Next Thread: helm me please, having trouble with Loop.
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






