SHOW:
|
|
- or go back to the newest paste.
| 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 | - | Pepe joe; |
| 22 | + | |
| 23 | - | |
| 23 | + | |
| 24 | - | joe.x = 0; |
| 24 | + | |
| 25 | - | joe.y = 1; |
| 25 | + | |
| 26 | - | joe.z = 2; |
| 26 | + | |
| 27 | - | |
| 27 | + | Pepe joe = Pepe(0,1,2); |
| 28 | - | Juan johnny = {joe,18};
|
| 28 | + | |
| 29 | - | |
| 29 | + | Juan johnny = Juan(joe,18); |
| 30 | ||
| 31 | - | |
| 31 | + | |
| 32 | ||
| 33 | return EXIT_SUCCESS; | |
| 34 | } |