P
pmatos
Hi all,
I've a problem I'm not able to solve with iterators and to examplify
the problem I've created a minimal program which results in the same
error:
#include <iostream>
#include <list>
using namespace std;
struct _foo {
int a;
};
typedef struct _foo foo;
int main() {
list<foo*> * var;
var = new list<foo*>[5];
for(int i = 0; i < 5; i++)
for(list<foo*>::const_iterator it = var.begin(); it !=
var.end(); it++)
cout << it->a << endl;
delete[] var;
return 0;
}
What's the problem with it->a?
I get from g++:
test.cc: In function `int main()':
test.cc:20: error: request for member `a' in
`*(&it)->std::_List_iterator<_Tp,
_Ref, _Ptr>:perator-> [with _Tp = foo*, _Ref = foo* const&, _Ptr =
foo*
const*]()', which is of non-class type `foo* const'
Can't understand the issue...
Can somebody help?
Cheers,
Paulo Matos
I've a problem I'm not able to solve with iterators and to examplify
the problem I've created a minimal program which results in the same
error:
#include <iostream>
#include <list>
using namespace std;
struct _foo {
int a;
};
typedef struct _foo foo;
int main() {
list<foo*> * var;
var = new list<foo*>[5];
for(int i = 0; i < 5; i++)
for(list<foo*>::const_iterator it = var.begin(); it !=
var.end(); it++)
cout << it->a << endl;
delete[] var;
return 0;
}
What's the problem with it->a?
I get from g++:
test.cc: In function `int main()':
test.cc:20: error: request for member `a' in
`*(&it)->std::_List_iterator<_Tp,
_Ref, _Ptr>:perator-> [with _Tp = foo*, _Ref = foo* const&, _Ptr =
foo*
const*]()', which is of non-class type `foo* const'
Can't understand the issue...
Can somebody help?
Cheers,
Paulo Matos