Skip to content

Instantly share code, notes, and snippets.

Created May 7, 2011 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/960160 to your computer and use it in GitHub Desktop.
Save anonymous/960160 to your computer and use it in GitHub Desktop.
vector <pair<string, int> >& h
#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