playground/cpp/04-pointers.cpp
2022-07-17 20:42:42 +02:00

29 lines
765 B
C++

#include <iostream>
#include <string>
int main() {
std::string tapa = "calamares";
std::string* pointer = &tapa;
std::cout << "tapa " << tapa << "\n";
std::cout << "&tapa " << &tapa << "\n";
std::cout << "pointer " << pointer << "\n";
std::cout << "*pointer " << *pointer << "\n\n";
tapa = "albondigas";
std::cout << "tapa " << tapa << "\n";
std::cout << "&tapa " << &tapa << "\n";
std::cout << "pointer " << pointer << "\n";
std::cout << "*pointer " << *pointer << "\n\n";
*pointer = "croquetas de jamón";
std::cout << "tapa " << tapa << "\n";
std::cout << "&tapa " << &tapa << "\n";
std::cout << "pointer " << pointer << "\n";
std::cout << "*pointer " << *pointer << "\n";
return 0;
}