pabloliva87

Ej3C++

Mar 20th, 2012
36
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. {
  8.     int x;
  9.     int y;
  10.     int z;
  11.     Pepe(int fn, int sn, int tn)            /* struct constructor */
  12.     {
  13.         x = fn;
  14.         y = sn;
  15.         z = tn;
  16.     }
  17. };
  18.  
  19. struct Juan
  20. {
  21.     Pepe& pp;
  22.     int a;
  23.     Juan (Pepe p, int fn): pp(p),a(fn){}        /* struct constructor */
  24. };
  25.  
  26. int main (void)
  27. {
  28.  
  29.     Pepe joe = Pepe(0,1,2);
  30.  
  31.     Juan johnny = Juan(joe,18);
  32.  
  33.     cout << "Pepe: " << sizeof(joe) << endl << "Juan: " << sizeof(johnny) << endl << "Int: " << sizeof(int) << endl;
  34.  
  35.     return EXIT_SUCCESS;
  36. }
Add Comment
Please, Sign In to add comment