I have the following code in a header file:
#include <string>
using std::string;
#include <map>
using std::map;
#include <utility>
using std::pair;
#include "share.h"
#include "bond.h"
#include "projectEnumsDefines.h"
namespace mtm {
class Account {
string id;
double money;
RequestType type;
map<share, int> shares;
map<bond, int> bonds;
public:
void checkBondsAndUpdate() {
for(auto &it1 : bonds) {
bond bond = it1.first;
}
}
// class implementation
};
}
i'm trying to access the bond keys in checkBondsAndUpdate by iterating on the "bonds" map.
however on the line "bond bond = it1.first;" it given an error "Field first
could not be resolved". what could be the problem here? thanks
EDIT: it works if i do
pair<bond,int> pair = it1;
bond bond = pair.first;
instead of
bond bond = it1.first;
the only question is why..