C
cylin
Dear all,
How do I change the codes in for-loop to print the value(m_dblXMax) in a
list?
Please help, thanks.
----------------------------------------------------------------------------
------------------
#include <iostream>
#include <list>
using namespace std;
typedef list<void*> List;
typedef List::iterator ListIterator;
class test {
public:
test():m_dblXMax(100) {}
double m_dblXMax;
};
int main()
{
List mylist;
test *c=new test;
c->m_dblXMax=1000;
mylist.push_back(c);
test *d=new test;
d->m_dblXMax=1001;
mylist.push_back(d);
for (ListIterator i=mylist.begin();i!=mylist.end();i++) {
// Got a error left of '->m_dblXMax' must point to class/struct/union
cout << (*i)->m_dblXMax << endl;
}
delete c;
delete d;
cin.get();
return 0;
}
How do I change the codes in for-loop to print the value(m_dblXMax) in a
list?
Please help, thanks.
----------------------------------------------------------------------------
------------------
#include <iostream>
#include <list>
using namespace std;
typedef list<void*> List;
typedef List::iterator ListIterator;
class test {
public:
test():m_dblXMax(100) {}
double m_dblXMax;
};
int main()
{
List mylist;
test *c=new test;
c->m_dblXMax=1000;
mylist.push_back(c);
test *d=new test;
d->m_dblXMax=1001;
mylist.push_back(d);
for (ListIterator i=mylist.begin();i!=mylist.end();i++) {
// Got a error left of '->m_dblXMax' must point to class/struct/union
cout << (*i)->m_dblXMax << endl;
}
delete c;
delete d;
cin.get();
return 0;
}