#include <iostream>
#include <vector>
using namespace std;
class ctcChanID
    void GetInfo(ctcChanID *m);
    int chanID;
    int type;
    string DN;
    int clientID;
void ctcChanID::GetInfo(ctcChanID *m)
int main()
    vector<ctcChanID*> _ctc;
    for(int i = 0; i < 2 ; i++)
        ctcChanID *a = new ctcChanID;
        cout << a << endl;
        a->chanID = i;
        a->type = 3;
        a->DN = "374847";
        a->clientID = 0;

    vector<ctcChanID*>::iterator iter;
    for(iter = _ctc.begin(); iter != _ctc.end(); ++iter)
           cout << *iter->chanID << endl;
    return 0;

when I compile the codes, it always generate the error:
error: request for member ‘chanID’ in ‘* iter. __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> [with _Iterator = ctcChanID**, _Container = std::vector<ctcChanID*, std::allocator<ctcChanID*> >]()’, which is of non-class type ‘ctcChanID*’

I cannot understand it,

10 Years
Discussion Span
Last Post by Narue

>I really hope that is a typo and you meant: "solveD it already"....
As do I. It takes some big rocks to demand such a thing when you have three post and no discernible reputation in the community.

Anyway, in either case, it would be useful to know the answer. Change this:

cout << *iter->chanID << endl;

To this:

cout << (*iter)->chanID << endl;

The order of operations is such that the -> operator was acting on the iterator itself, not the item that the iterator refers to.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.