Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <string>
- using namespace std;
- struct testStr
- {
- string str;
- int a;
- };
- class testCls
- {
- public:
- testCls ()
- {
- cout << "Constructor" << endl;
- }
- ~testCls ()
- {
- cout << "Destructor" << endl;
- }
- void fillList()
- {
- testStr tmp;
- for (int i =0; i<10; i++)
- {
- char t[2];
- t[0] = i + 61;
- t[1] = '\0';
- tmp.str = t;
- tmp.a = i;
- lst.push_back (tmp);
- }
- }
- void printList()
- {
- list<testStr>::iterator it;
- for (it = lst.begin(); it != lst.end(); it++)
- {
- cout << it->str << ", "<< it->a << endl;
- }
- }
- private:
- list <testStr> lst;
- };
- int main()
- {
- testCls cls;
- cls.fillList();
- cls.printList();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement