#include<iostream>
#include<map>
#include<string>
using namespace std;
class Card{
public :
Card(){id=0;}
Card(int _id){ id=_id; }
~Card(){}
Card(const Card& object){ id=object.id;}
int getID(){return id;}
void setID(int _id){ id=_id; }
//void print(){cout<<getID()<<endl;}
virtual print(){ cout<<getID()<<endl;}//虚函数,子类可重定义虚函数以实现动态绑定
private:
//string name;
int id;
};
class SkillCard: public Card{//继承访问控制
public:
SkillCard(string name){skillName=name;}
string getSkillName(){return skillName;}
void setSkillName(string name){skillName=name;}
virtual print(){cout<<getSkillName()<<endl;}
private:
string skillName;
};
class RowCard:public Card{
public:
//RowCard();
RowCard(string name){rowName=name;}
string getRowName(){return rowName;}
void setRowName(string name){rowName=name;}
virtual print(){cout<<getRowName()<<endl;}
private:
string rowName;
};
class EqCard:public Card{
public:
EqCard(string name){eqName=name;}
string getEqName(){return eqName;}
void setEqName(string name){eqName=name;}
virtual print(){cout<<getEqName()<<endl;}
private:
string eqName;
};
int main()
{
Card liubei(1);
RowCard guanyu("guanyu");
guanyu.setID(2);
SkillCard qianrenzhan("qianrenzhan");
qianrenzhan.setID(100);
EqCard longdao("longdao");
longdao.setID(10);
map<int,Card> cardMap; //STL还不太熟,今天看了几眼map
cardMap.insert(pair<int,Card>(1,guanyu));
cardMap.insert(pair<int,Card>(10,longdao));
cardMap.insert(pair<int,Card>(100,qianrenzhan));
map<int,Card>::iterator it; //这个东东叫什么来着,迭代器,挺好的,告别了i,j,k了。
it=cardMap.find(100);
cout<<it->second.getID()<<endl;
return 0;
}