類的成員,我有一個類定義爲訪問使用矢量
typedef std::string Name;
typedef int Age;
typedef std::string Level;
class Employee
{
public:
// Employee (arguments);
// virtual ~Employee();
void name(Name const & name) { name_ = name; }
Name name() const { return name_; }
void age(Age const & age) { age_ = age; }
Age age() const { return age_; }
void level(Level const & level) { level_ = level; }
Level level() const { return level_; }
private:
Name name_;
Age age_;
Level level_;
};
std::vector<Employee> read_file(std::string filename);
std::vector<Employee> employees = read_file("data.txt");
std::cout << employees.size() << std:: endl;
for(std::vector<Employee>::iterator it = employees.begin(); it != employees.end(); ++it)
{
std::cout << *it << std::endl;
}
有我的方式來訪問使用上面定義這個向量Employee類的成員?我想要構建一個以員工級別爲關鍵值的容器map
。
謝謝:)我在找'it->' – vivekv80