I have simple question. According to other examples my iteration for is correct but Eclipse throws me errors... My Function
billing::billing(std::istream &is) {
unsigned day;
std::string number;
float time;
struct call call;
while (!is.eof()) {
is >> day >> number >> time;
call.day = day;
call.number = number;
call.time = time;
blng_.push_back(call);
}
for(std::vector<call>::const_iterator it; it = blng_.begin(); it != blng_.end(); ++it)
// THROWS HERE ERRORS!
std::cout << it->day << std::endl;
}
After compiling he throws me something like that
expected a type, got 'call' billing.cpp
'it' was not declared in this scope billing.cpp
expected ';' before 'it' billing.cpp
expected ')' before ';' token billing.cpp
invalid type in declaration before 'it' billing.cpp
template argument 2 is invalid billing.cpp
the value of 'call' is not usable in a constant expression billing.cpp
type/value mismatch at argument 1 in template parameter list for
'template<class _Tp, class _Alloc> class std::vector' billing.cpp
According to this How do I iterate over a Constant Vector? topic it should be working but it isn't and I have no freq idea why. When i change this whole std::vectro... to auto it works!