Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * fichero: varmonticulo.cpp
- *
- * proposito: mostrar la declaracion de variables locales
- *
- * compilar: $ g++ -o varmonticulo varmonticulo.cpp
- * $ make varmonticulo
- * ejecutar: $ ./varmonticulo
- */
- #include <iostream>
- using namespace std;
- int
- main() {
- // Aputadores a variables de diferentes tipos
- int *pInt = new int;
- bool *pBool = new bool;
- double *pDouble = new double;
- // Obtenemos sus direcciones
- cout << "Valores de apuntadores " << endl;
- cout << "pInt: " << pInt << endl;
- cout << "pBool: " << pBool << endl;
- cout << "pDouble: " << pDouble << endl;
- // Ahora miramos sus valores
- cout << "Valores de apuntadores " << endl;
- cout << "pInt: " << *pInt << endl;
- cout << "pBool: " << *pBool << endl;
- cout << "pDouble: " << *pDouble << endl;
- // Las inicializamos
- *pInt = 10;
- *pBool = false;
- *pDouble = -102.23e12;
- // Ahora vemos sus valores
- cout << "Valores de apuntadores " << endl;
- cout << "pInt: " << *pInt << endl;
- cout << "pBool: " << *pBool << endl;
- cout << "pDouble: " << *pDouble << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment