Ken
Ken

Reputation: 31161

Nested template list error

In header:

list< SKPair<VALUETYPE> > *values[256];

In implementation:

const list< SKPair<VALUETYPE> > *bucket = values[0];
typename list< SKPair<VALUETYPE> >::iterator it = bucket.begin();

The gcc compiler complains about the second line:

error: request for member ‘begin’ in ‘bucket’, which is of non-class type ‘const std::list<SKPair<int>, std::allocator<SKPair<int> > >*’

(Here in main I create a test instance of my class where VALUETYPE is int.) Any idea what I'm doing wrong?

Upvotes: 0

Views: 60

Answers (2)

Anthony
Anthony

Reputation: 12397

bucket is declared as a pointer, so you need a dereferencing operator to access its members:

auto it = bucket->begin();

Should do the trick if you have C++11's auto available.

Upvotes: 1

Kirill Kobelev
Kirill Kobelev

Reputation: 10557

Write:

typename list< SKPair<VALUETYPE> >::iterator it = bucket->begin();

The -> is needed here.

Upvotes: 3

Related Questions