- 111 名前:デフォルトの名無しさん mailto:sage [2008/08/10(日) 12:46:00 ]
- mapに関する質問です。以下のようなプログラムをビルドした際に、
(1)または(2)のように記述するとエラーとなりました。 error C2662: 'MYTYPE::hoge' : 'const MYTYPE' から'MYTYPE &' へ 'this' ポインタを変換できません なぜ(1)(2)だと失敗するのか、(3)だと成功するのか教えていただけないでしょうか。 ※環境 WindowsVista, Visual C++ 2008 Express map<string, vector<MYTYPE> > mapA; for(map<string, vector<MYTYPE> >::const_iterator it = mapA.begin(); it != mapPitcher.end(); ++it) { // イテレータを用いた方法 for(vector<MYTYPE>::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++itv) { it2->hoge(); // (1)コンパイルエラー } // イテレータを用いない方法 for(vector<MYTYPE>::size_type size = 0; size != it->second.size(); ++size) { it->second[size].hoge(); // (2)コンパイルエラー mapA[it->first][size].hoge(); // (3)成功 } }
|

|