私はマルチマップを使ってopenframeworksを使っていくつかのデータを保存しています。私は、マルチマップを作成することができますが、私はその中のデータを印刷しようとすると、私はメモリアドレスを印刷し、値を取得することはできません。マルチマップから値をプリントできません
基準(セクション "マップに格納オブジェクト"):http://openframeworks.cc/ofBook/chapters/stl_map.html
.hファイル:
class xyPos {
public:
float x, y;
xyPos(float xPos, float yPos) {
x = xPos;
y = yPos;
}
//return ofVec2f(x, y);
};
static multimap<string, xyPos> posMap;
static multimap<string, xyPos>::iterator xyMapIterator;
.cppファイル:私も試みた
for(int i = 0; i < 10; i ++) {
for(int j = 0; j < 10; j ++) {
posMap.insert(make_pair("null", xyPos(i, j));
}
}
:
for(int i = 0; i < 10; i ++) {
for(int j = 0; j < 10; j ++) {
xyPos *p = new xyPos(i, j);
xyMap.insert(make_pair("null", *p);
}
}
cout << "xyMap:\n";
for(xyMapIterator = xyMap.begin(); xyMapIterator != xyMap.end(); ++ xyMapIterator) {
cout << (*xyMapIterator).first << " => " << (*xyMapIterator).second << "\n";
} //will only compile with &(*xyMapIterator).second so i only have ["null", memory address] in the output
カット[MCVE]までであり、それはmultimap'または反復 'とは全く関係ありません発見します。 – juanchopanza