malfist
November 21st, 2007, 01:04 AM
Hey, I have this vector of structs and I can't seem to add any data to it, I get the error "insufficient contextual information to determine type".
Any help you be appreciated, heres some code snippets:
struct bid {
int amount;
string id;
bid(int a, string i) {
amount = a;
id = i;
}
};
class BidManager{
private:
int offers;
vector<bid> bids();
public:
BidManager();
void insertBid(bid& b);
void printBids() const;
};
and the insertBid part (where the error is occuring, on every insertion or push_back)
void BidManager::insertBid(bid& b) {
if(offers = 0)
bids.insert(bids.begin(),b);
else if(b.amount <= ((bid)bids.at(0)).amount) {
bids.insert(bids.begin(),b);
return;
}
else {
offers++;
vector<bid>::iterator it = bids.begin();
for(int i=0;i<offers;i++) {
if(b.amount > ((bid)bids.at(i)).amount){ //next!
it++;
continue;
else {
bids.insert(it,b); //if it is less than than, obviously, it needs to go infront of it
return;
}
}
//reached the end without finding a sport for it
//must be largest
bids.push_back(b);
}
}
Any help you be appreciated, heres some code snippets:
struct bid {
int amount;
string id;
bid(int a, string i) {
amount = a;
id = i;
}
};
class BidManager{
private:
int offers;
vector<bid> bids();
public:
BidManager();
void insertBid(bid& b);
void printBids() const;
};
and the insertBid part (where the error is occuring, on every insertion or push_back)
void BidManager::insertBid(bid& b) {
if(offers = 0)
bids.insert(bids.begin(),b);
else if(b.amount <= ((bid)bids.at(0)).amount) {
bids.insert(bids.begin(),b);
return;
}
else {
offers++;
vector<bid>::iterator it = bids.begin();
for(int i=0;i<offers;i++) {
if(b.amount > ((bid)bids.at(i)).amount){ //next!
it++;
continue;
else {
bids.insert(it,b); //if it is less than than, obviously, it needs to go infront of it
return;
}
}
//reached the end without finding a sport for it
//must be largest
bids.push_back(b);
}
}