Ko‘rsatkich qiymatini o‘zgartirish
Ko‘rsatkich qiymatini o‘zgartirish
Ko‘rsatkichning qiymatini ham o‘zgartirishingiz mumkin. Biroq e’tibor bering, bu asl o‘zgaruvchining qiymatini ham o‘zgartiradi:
Misol
string food = "Pizza";
string* ptr = &food;
// Output the value of food (Pizza)
cout << food << "\n";
// Output the memory address of food (0x6dfed4)
cout << &food << "\n";
// Access the memory address of food and output its value (Pizza)
cout << *ptr << "\n";
// Change the value of the pointer
*ptr = "Hamburger";
// Output the new value of the pointer (Hamburger)
cout << *ptr << "\n";
// Output the new value of the food variable (Hamburger)
cout << food << "\n";
O‘zingiz sinab ko‘ring »
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
