Article ID: 156899
Article Last Modified on 2/11/2004
<utility>
template<class first, class second> inline
pair<first, second> make_pair(const first& _X, const second& _Y)
NOTE: The class/parameter names in the prototype may not match the
version in the header file. Some have been modified to improve readability.
///////////////////////////////////////////////////////////////////////
// Compile options needed: none
//
// mkpair.cpp: Illustrates how to use the make_pair function.
//
// Functions: make_pair - creates an object pair containing two data
// elements of any type.
//
// Written by Mark Hagen
// of Microsoft Technical Support
// Copyright (c) 1996 Microsoft Corporation.
// All rights reserved.
///////////////////////////////////////////////////////////////////////
/* Compiler options needed: none
*/
#include <utility>
#include <iostream>
/* STL pair data type containing int and float
*/
using namespace std;
typedef struct pair<int,float> PAIR_IF;
void main(void)
{
PAIR_IF pair1=make_pair(18,3.14f);
cout << pair1.first << " " << pair1.second << endl;
pair1.first=10;
pair1.second=1.0f;
cout << pair1.first << " " << pair1.second << endl;
}
Program Output is: 18 3.14 10 1
Additional query words: STL STLSample make_pair pair kbstl kbTemplate
Keywords: kbinfo kbcode KB156899