0

Declaring pointer:

int a; int *x=&a;

x occupies 8 bytes of memory

Likewise if we declare a reference to a variable:

int a; int &x =a;

How much memory does the the reference to a occupy?

user1825567
  • 153
  • 1
  • 9

1 Answers1

0

That's undefined. Not as in Undefined Behavior, but the question simply doesn't have an answer.

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • Well, it could have an answer *when using a particular compiler on a particular piece of code*. It doesn't have an answer in a general sense. I'd say "unspecified" fits the C++ terminology better. – Bartek Banachewicz May 22 '17 at 12:54
  • @BartekBanachewicz: Actually, we see in real compilers that it varies depending on the exact usage. Calling it "unspecified" suggests there's a compiler-dependent single value that's just unknown. – MSalters May 22 '17 at 12:57