运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
前往 Spaces
#include <iostream> #include <string> using namespace std; int main() { string food = "Pizza"; string* ptr = &food; // Output the value of food cout << food << "\n"; // Output the memory address of food cout << &food << "\n"; // Access the memory address of food and output its value cout << *ptr << "\n"; // Change the value of the pointer *ptr = "Hamburger"; // Output the new value of the pointer cout << *ptr << "\n"; // Output the new value of the food variable cout << food << "\n"; return 0; }
披萨
0x6dfed4
披萨
汉堡
汉堡