私はマップを保持する親クラスを持っています。そして、何らかの理由でそのクラスを継承するために使用した子クラスは、私がなぜ立つことができないのですか?マップ内の値。map継承
//HEADER FILE
#include <iostream>
#include <map>
using namespace std;
//////PARENT CLASS
struct TTYElementBase
{
//some code here
};
class element
{
public:
std::map<char,std::string> transMask;
std::map<char,std::string>::iterator it;
void populate();
};
//////CHILD CLASS .HPP
class elementV : public element
{
public :
std::string s1;
std::string s2;
elementV();
friend ostream &operator<< (ostream &, const elementV &);
void transLateMask();
};
//CPP FILE
#include "example.h"
#include <iostream>
elementV::elementV()
{
}
void elementV::transLateMask()
{
for (it=transMask.begin() ; it != transMask.end(); it++)
cout << (*it).first << endl;
}
int main()
{
elementV v;
v.transLateMask();
}
// ' OUTPUT IS NOTHING I DONT KNOW WHY?'
出力は何もありませんが、私は親クラスフロンマップをアクセスもする必要があり、私は間違って何をやっているの?次のように私のコードがありますか
任意のヘルプ、私は非常にgratefullなり
おかげ
プログラムをコンパイルしますが、実行時に失敗しましたか? – hmjd
マップに「D」で索引付けされたエントリがありますか? –
マップの表示方法を表示できますか? 'D'が存在しない場合は、未定義の振る舞いであるpast-the-endイテレータを参照しています。 – hmjd