Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /////////////////////////////////////
- struct T
- {
- int n;
- T *p;
- }t1;
- void monitor(T *jkhjkhkj);
- T t2;
- //////////////////////////////////////////////////////
- int main()
- {
- int n1;
- T t[5], t3, t4;
- t1.n = 11;
- t2.n = 22;
- t3.n = 33;
- t4.n = 44;
- t1.p = &t2;
- t2.p = &t3;
- t3.p = &t4;
- t[1].n = 100;
- t[2].n = 200;
- t[3].n = 333;
- t[4].n = 4444;
- for(int i = 1; i < 5; i++)
- {
- //monitor(&t[i]);
- }
- // - - - - - - - - -
- T *pObj = &t1;
- for(int i = 10; i < 14; i++)
- {
- monitor(pObj);
- pObj = pObj->p;
- }
- }
- //////////////////////////////////////////////////////
- void monitor(T *pt)
- {
- cout << "pt.n = " << pt->n;
- cout << ", pt.p = " << pt->p << endl;
- cout << "- - - - - - - - - -"<< endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement