Hi all,

I am storing some objects in the list and the i am trying to access them one by one. Each object consists of two strings and one integer.

The problem is that i cannot access these objects through the iterator.
1.How can i access these objects?

Qt Code:
  1. #include <stdlib.h>
  2. #include <iostream>
  3. #include <map>
  4. #include <list>
  5. using namespace std;
  6.  
  7.  
  8. class A{
  9. public:
  10. string x;
  11. string y;
  12. int z;
  13. };
  14.  
  15. list<A> G_QUERY_LIST;
  16. list<A>::iterator it;
  17.  
  18.  
  19. void create_new_query()
  20. {
  21. string name;
  22. string query;
  23. string results;
  24. cout << "Please enter a name for this query: ";
  25. cin >> name;
  26. cout << "Please enter the query you want to execute: ";
  27. cin >> query;
  28. A ena;
  29. ena.x = name;
  30. ena.y = query;
  31. G_QUERY_LIST.push_back(ena);
  32. }
  33.  
  34.  
  35. int main() {
  36. create_new_query();
  37. create_new_query();
  38. cout << "mylist contains:";
  39. for (it=G_QUERY_LIST.begin(); it!=G_QUERY_LIST.end(); it++)
  40. cout<< *it.ena.x;
  41. cout << endl;
  42.  
  43.  
  44.  
  45. return 0;
  46.  
  47. }
To copy to clipboard, switch view to plain text mode 

Many thanks in advance.