Created
May 7, 2011 03:04
-
-
Save anonymous/960160 to your computer and use it in GitHub Desktop.
vector <pair<string, int> >& h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <utility> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
// void solve(vector <pair<string, int> >& h){ | |
// ↑この様に参照で定義したいが、コンパイラに怒られるので | |
// ↓現状ポインタで定義している | |
void solve(const vector<pair<string, int> >* h){ | |
cout << h->operator[](0).first; | |
} | |
int main(){ | |
const int N = 2; | |
vector<pair<string, int> > h(N); | |
h[0] = make_pair("aa", 11); | |
h[1] = make_pair("bb", 22); | |
solve(&h); | |
return 0; | |
} | |
// http://hibari.2ch.net/test/read.cgi/tech/1291571263/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment