c++ - Does reference variable occupy memory? -


this question has answer here:

i have read reference variable shares same memory address original variable takes space on stack. , reference has same memory address original variable, known alias.

so, question how memory allocations done reference variables ?

8.3.2 references §4

it unspecified whether or not reference requires storage

that being said, if reference needs storage, typically needs storage pointer:

struct p {     int* p; };  struct r {     int& r; };  static_assert(sizeof(p) == sizeof(r), "sizeof(p) == sizeof(r)"); 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -