pabloliva87

Ej3C++

Feb 13th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. struct Pepe {
  7.     int x;
  8.     int y;
  9.     int z;
  10.     Pepe(int fn, int sn, int tn) {          /* struct constructor */
  11.         x = fn;
  12.         y = sn;
  13.         z = tn;
  14.     }
  15. };
  16. typedef struct Pepe Pepe;
  17.  
  18. struct Juan {
  19.     Pepe& pp;
  20.     int a;
  21.     Juan (Pepe p, int fn): pp(p),a(fn){}        /* struct constructor */
  22. };
  23. typedef struct Juan Juan;
  24.  
  25. int main (void) {
  26.  
  27.     Pepe joe = Pepe(0,1,2);
  28.  
  29.     Juan johnny = Juan(joe,18);
  30.  
  31.     cout << "Pepe: " << sizeof(joe) << endl << "Juan: " << sizeof(johnny) << endl << "Int: " << sizeof(int) << endl;
  32.  
  33.     return EXIT_SUCCESS;
  34. }
Add Comment
Please, Sign In to add comment