<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hola que tal como estais.<div><br></div><div>Tengo el siguiente código :</div><div><br></div><div><div>#include <iostream></div><div>  </div><div>void swap(int *x, int *y);</div><div><br></div><div>int main()</div><div>{</div><div>    int x = 5, y = 10;</div><div>  </div><div>    std::cout << "Main. Before swap, x: " << x </div><div>              << " y: " << y << "\n";</div><div>    swap(&x, &y);</div><div>    std::cout << "Main. After swap, x: " << x </div><div>              << " y: " << y << "\n";</div><div>    return 0;</div><div>}</div><div>  </div><div>void swap(int *px, int *py)</div><div>{</div><div>    int temp;</div><div>  </div><div>    std::cout << "Swap. Before swap, *px: " << *px </div><div>              << " *py: " << *py << "\n";</div><div>  </div><div>    temp = *px;</div><div>    *px = *py;</div><div>    *py = temp;</div><div>  </div><div>    std::cout << "Swap. After swap, *px: " << *px </div><div>              << " *py: " << *py << "\n";</div><div>}</div><div><br></div><div>que produce la siguiente salida :</div><div><br></div><div><div>Main. Before swap, x: 5 y: 10</div><div>Swap. Before swap, *px: 5 *py: 10</div><div>Swap. After swap, *px: 10 *py: 5</div><div>Main. After swap, x: 10 y: 5</div></div><div><br></div><div>No entiendo por qué si en main después del primer Main. Before swap salta a Swap. Before swap.</div><div><br></div><div>¿Me lo podeis explicar por favor?</div><div><br></div><div>Un saludo.</div><br><font style="" color="#548dd4" face="Arial"><i><b>Oscar </b></i></font><br><font style="" color="#e36c09">Administrador de sistemas.</font><br></div>                                         </div></body>
</html>