I've been trying to learn more about storage stuff using c++. I knew that they are store in the stack therefore the order was the contrary. However, why when i want to get the reference of the string, it shows me that the storage for that is about 28 instead of 24 since 56-28=28.
here is my code:
#include <iostream>
int main(){
std::string name = "name";
int age = 18;
std::string last = "lastname";
std::cout << &name << "\n"; //140701916868960
std::cout << &age << "\n"; //140701916868956
std::cout << &last << "\n"; //140701916868928
}
std::stringby doing simple pointer arithmetic.