Hi,
Here is the code:
#include <QDebug>
#include <QList>
class Node
{
public:
int a;
int b;
};
int main(int argc, char *argv[])
{
//case1
QList<int> list1;
list1.append(10);
list1.append(3);
QList<int>::iterator i;
for (i = list1.begin(); i != list1.end(); ++i)
qDebug() << *i;
//case2
QList<Node> list2;
Node no = {10, 3};
list2.append(no);
QList<Node>::iterator j;
for (j = list2.begin(); j != list2.end(); ++j)
//here ???
;
}
#include <QDebug>
#include <QList>
class Node
{
public:
int a;
int b;
};
int main(int argc, char *argv[])
{
//case1
QList<int> list1;
list1.append(10);
list1.append(3);
QList<int>::iterator i;
for (i = list1.begin(); i != list1.end(); ++i)
qDebug() << *i;
//case2
QList<Node> list2;
Node no = {10, 3};
list2.append(no);
QList<Node>::iterator j;
for (j = list2.begin(); j != list2.end(); ++j)
//here ???
;
}
To copy to clipboard, switch view to plain text mode
In case 2, how can i access the a and b from each node?
Thanks
Bookmarks