Here is a memory map; a representation of memory as a sequence of blocks:

    address    01   02   03
             +----+----+----+...
data within  | 23 | 6f | 4a |
             +----+----+----+...

Now suppose we create a character:

char c = 'z';  // 'z' is 7a in hex

Further suppose c is stored at address 01, so our memory looks like so:

    address    01   02   03
             +----+----+----+...
data within  | 7a | 6f | 4a |
             +----+----+----+...

Now, let's create a pointer:

char* p = &c;  // point at c

p may be stored at address 02:

    address    01   02   03
             +----+----+----+...
data within  | 7a | 01 | 4a |
             +----+----+----+...

Here the pointer p is at address 02 and it points at address 01. That's the meaning of p = &c;. When we dereference the pointer p (at address 02) we look at what's in the address pointed at by p. That is, p points at address 01, and so dereferencing p means looking inside address 01.

Finally, lets create a reference:

char& r = c;

Here the memory layout doesn't change. That is, no memory is used to store r. r is a sort of alias for c, so when we refer to r we practically refer to c. r and c are conceptually one. Changing r means changing c, and changing c means changing r.

When you create a reference you must initialize, and once initialized you cannot re-initialize it with another target. That is, above the reference r means and forever will mean c.

Also related are const references. These are the same as a reference, except they are immutable:

const char& r = c;
r = 'y';  // error; you may not change c through r
c = 'y'   // ok. and now r == 'y' as well

We use const references when we are interested in reading the data but frown upon changing it. By using a const reference the compiler will not copy the data, so this gives us ideal performance, but also forbid us from changing the data, for correctness.

In a sense, you can say that references are a compile-time feature, whereas pointers are a runtime feature. So references are faster and cheaper than pointers, but come with certain constraints and implications. Like other compile-time-vs-runtime alternatives, we sometimes pick one over the other for performance, sometimes for static analysis and sometimes for flexibility.

Answer from wilhelmtell on Stack Overflow
Top answer
1 of 9
31

Here is a memory map; a representation of memory as a sequence of blocks:

    address    01   02   03
             +----+----+----+...
data within  | 23 | 6f | 4a |
             +----+----+----+...

Now suppose we create a character:

char c = 'z';  // 'z' is 7a in hex

Further suppose c is stored at address 01, so our memory looks like so:

    address    01   02   03
             +----+----+----+...
data within  | 7a | 6f | 4a |
             +----+----+----+...

Now, let's create a pointer:

char* p = &c;  // point at c

p may be stored at address 02:

    address    01   02   03
             +----+----+----+...
data within  | 7a | 01 | 4a |
             +----+----+----+...

Here the pointer p is at address 02 and it points at address 01. That's the meaning of p = &c;. When we dereference the pointer p (at address 02) we look at what's in the address pointed at by p. That is, p points at address 01, and so dereferencing p means looking inside address 01.

Finally, lets create a reference:

char& r = c;

Here the memory layout doesn't change. That is, no memory is used to store r. r is a sort of alias for c, so when we refer to r we practically refer to c. r and c are conceptually one. Changing r means changing c, and changing c means changing r.

When you create a reference you must initialize, and once initialized you cannot re-initialize it with another target. That is, above the reference r means and forever will mean c.

Also related are const references. These are the same as a reference, except they are immutable:

const char& r = c;
r = 'y';  // error; you may not change c through r
c = 'y'   // ok. and now r == 'y' as well

We use const references when we are interested in reading the data but frown upon changing it. By using a const reference the compiler will not copy the data, so this gives us ideal performance, but also forbid us from changing the data, for correctness.

In a sense, you can say that references are a compile-time feature, whereas pointers are a runtime feature. So references are faster and cheaper than pointers, but come with certain constraints and implications. Like other compile-time-vs-runtime alternatives, we sometimes pick one over the other for performance, sometimes for static analysis and sometimes for flexibility.

2 of 9
7

Time to go on a term-bashing spree, because these things always cause confusion.

  • A pointer is a memory address in its own right. Cue fancy diagram for how it happens in memory:

    | Address  | Value          |
    |----------|----------------|
    |0x1111    |0x1112          | <-- Pointer!
    |0x1112    |42              | <-- Pointed value
    |0x1113    |42              | <-- Some other value
    

    I've used a much smaller address size just for simplicity. Basically, 0x1111 is a pointer because its contents are the address of another value.

  • Dereferencing means examining the value of the address held in the pointer's value. Such fancy language can be confusing; basically, if I dereference 0x1111 I look at 0x1112 and get the value out of that address. Why? Because it's really useful and because assembly lets us do it too,

    mov rax, [r8]
    

    Is nasm/intel syntax for "look in r8, find that memory address, follow it and find the value at that memory address and put that in rax".

  • Pass by value. Pass by value means that when you create a function stack frame, which is the stack contents around a function, you copy every value that is an argument to wherever it goes. Registers, stack, wherever. Of course, if you copy a pointer's value, you're copying a memory address and thus creating another pointer pointing to the same memory. This is how functions like this:

    void add(int* x)
    {
        *x = *x + 7;
    }
    

    Work.

  • Pass by reference. What that function above does is essentially pass by reference semantics as you will see them in say C++. The crucial and possibly only difference as the implementation is likely identical at the assembly level is that a reference is something the C++ compiler understands. Since the compiler is the language this is important. C understands pointers and manipulating memory, and so do C compilers, but they'll let you do whatever you like. You can't re-assign a reference, for example,

    void cppadd(int& x)
    {
        int a = 7;
        x = &a; // doesn't work.
    }
    

So, to sum it up, references are on one level a language feature where the compiler understands where the source memory is and prevents modification of that source memory address. It understands you want to play with the value. Pointers are just that, memory addresses holding other memory addresses.

Wikipedia summarises it pretty well:

In the C++ programming language, a reference is a simple reference datatype that is less powerful but safer than the pointer type inherited from C. The name C++ reference may cause confusion, as in computer science a reference is a general concept datatype, with pointers and C++ references being specific reference datatype implementations.

Yes, I have mentioned C++ when this question is only C, but I feel it is prudent to clarify how a term has become somewhat confused with the addition of later languages.

🌐
University of Toronto
dgp.toronto.edu › ~patrick › csc418 › wi2004 › notes › PointersVsRef.pdf pdf
C/C++ Pointers vs References Consider the following code: Pointers References
The main effect of this is that the address can directly be manipulated if it is a pointer. ... References are the preferred way of indirectly accessing a variable. They are also a little · safer than pointers and, in some cases, are the only way to achieve a particular result such
Discussions

I am absolutely confused on the topic of references vs pointers
The main problem is that even in the language, a reference is the object, except it only behaves like that in some contexts, in other contexts, it behaves like a pointer. So, kinda, both statements are wrong and correct at the same time. Personally, I do consider the "a reference is a pointer with syntactic sugar" logic more useful. More on reddit.com
🌐 r/cpp
116
94
November 22, 2023
Syntax for pointers and references - do you prefer to put the * or & on the variable name or data type?
As you probably know, the language doesnt care. That said: It is part of the type. Put it with the type. The fact that anything else is even possible is a relic from C where "declaration reflects usage" was thought of as a good idea that is frankly ridiculous and overhauled. That is also why we declare function pointers as R(*ptr)(Args...) - but then you dont have to dereference function pointers because we noticed thats kind of pointless. The same with pointers/references to arrays. That syntax was decided upon 50+ years ago and now we are stuck with it. The only "good" argument for putting it with the identifier is: T* pointer, not_pointer; which we also inherited from C. The solution here is simple: Dont write stuff like that. If you really feel the need to declare multiple variables of different types in the same statement, then I feel entitled to ignore your opinion as invalid. What do coding standards say about this. Whatever their authors believe in. Notably coding standards can have outright bad things in them. Pretty sure the google coding standard advises against references "because they are confusing". For what its worth, the core guidelines suggest putting it with the type: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rl-ptr More on reddit.com
🌐 r/cpp_questions
55
8
August 13, 2023
C++ pointers and references
Its a big subject so don't worry too much. Memory management isn't hard in c++, just needs to be thought about. Memory is like a city. A pointer is an address to a specific address in the city. i.e. 742 Evergreen Terrace. Pointer++ will move the pointer to 743 Evergreen Terrace. Pointers are pretty arbitrary and flexible but if your not careful you end up reading data from the city dump instead of the city library. A reference is a more specific form of pointer. Its created from an object. i.e. SimponHouse& will point at 742 Evergreen Terrace. A reference can't be moved so will always point at 742 Evergreen Terrrace. You can demolish the house though and the reference is still pointing at the same address. Memory management is generally important in C++ as it will copy objects and every chance it gets and if you create them with the new operator it won't delete them. More on reddit.com
🌐 r/learnprogramming
17
16
July 20, 2018
C++ Pointers and References : r/learnprogramming
🌐 r/learnprogramming
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › pointers-vs-references-cpp
Pointers vs References in C++ - GeeksforGeeks
2 weeks ago - A reference acts as an alias (another name) for an existing variable. Both are commonly used for parameter passing and efficient data manipulation. A pointer is a variable that stores the memory address of another variable.
🌐
NTU
www3.ntu.edu.sg › home › ehchua › programming › cpp › cp4_PointerReference.html
C++ Pointers and References
To get the value pointed to by a pointer, you need to use the dereferencing operator * (e.g., if pNumber is a int pointer, *pNumber returns the value pointed to by pNumber. It is called dereferencing or indirection). To assign an address of a variable into a pointer, you need to use the address-of operator & (e.g., pNumber = &number). On the other hand, referencing and dereferencing are done on the references implicitly.
🌐
Daily.dev
app.daily.dev › home › playful programming › pointers and references in c/c++
Pointers and References in C/C++ | daily.dev
March 16, 2026 - An introductory guide to pointers and references in C/C++. Covers what pointers are, how the dereference (*) and address-of (&) operators work, single and double pointers with memory address examples, and the difference between pass-by-reference and pass-by-value in functions.
🌐
Reddit
reddit.com › r/cpp › i am absolutely confused on the topic of references vs pointers
r/cpp on Reddit: I am absolutely confused on the topic of references vs pointers
November 22, 2023 -

On one hand, there is the Brief Introduction To C++’s Model For Type- And Resource-Safety which is considered to be an authoritative source for the obvious reason that Bjarne Stroustrup himself co-authored it, and it says :

"A reference is a restricted form of a pointer with some added syntactic sugar, so our techniques for pointers also deal with references."

On the other hand, there is the C++ FAQ which is also considered to be an authoritative source, and it says this about references:

"Important note: Even though a reference is often implemented using an address in the underlying assembly language, please do not think of a reference as a funny looking pointer to an object. A reference is the object, just with another name. It is neither a pointer to the object, nor a copy of the object. It is the object. There is no C++ syntax that lets you operate on the reference itself separate from the object to which it refers."

To me, it appears that these statements contradict each other, or do they? I don't know anymore. Could someone enlighten me and for once and for all, define exactly what a reference is, and what's the difference between that and a pointer? Thanks.

Top answer
1 of 5
118
The main problem is that even in the language, a reference is the object, except it only behaves like that in some contexts, in other contexts, it behaves like a pointer. So, kinda, both statements are wrong and correct at the same time. Personally, I do consider the "a reference is a pointer with syntactic sugar" logic more useful.
2 of 5
63
I think the problem you are running into here is that these quotes somewhat muddle semantics with implementation. Let’s separate the two more explicitly, and then why these quotes aren’t actually incompatible or contradictory with each other will become more clear: Pointer’s Semantics A pointer is a distinct value type. It has a defined size on a given platform, which can be obtained by sizeof(void*). On a platform with a true 64 bit address space, this will return 8. All pointers to any object type will have this same size: sizeof(T*) == sizeof(U*). The value of a pointer is an actual, real memory location. You can introspect this directly; if you print a pointer without dereferencing it, the value printed is the memory address value the pointer holds. Basically, pointers are “true” value types in an of themselves and can exist independently of having an object to point to. This is why you can have a null pointer. And since they are true value types, they have their own definition of the following operations, independent of the type they point to: To compare a pointer means to compare the memory address, not the content at that memory address. To copy/assign a pointer means to copy/assign the memory address, not the content at that memory address. Taking the address of a pointer will produce the address of the pointer object itself, not the pointed to content. “Dereferencing” a pointer produces a reference to the pointed to content. I know, it’s confusing. It made more sense in C when there wasn’t a distinct thing called a reference, so pointers were said to have “reference semantics” and thus “dereferencing” them produced the actual content. When we say a type is “pointer like,” we mean it models the properties above. This is why the smart pointers behave the way they do. It’s also why std::span is so confusing. std::span looks like a container, so you expect it to behave the way a reference to a container would: comparing it would compare the elements in the span. But you can reassign spans, and that assignment doesn’t reassign the underlying elements, it just reassigns the underlying pointer to point to new elements. So to be consistent, the standard chose the lesser of two evils and made span model a pointer, and thus has pointer semantics all around. When you compare a span, you’re asking “do these spans provide a view onto literally the same content in memory,” just like comparing a pointer. In C++20 they formalized this “container reference API but pointer semantics” notion with the view concept. Reference’s Semantics A reference is not actually a distinct type, just like that the second quote states: there is no actual object that “represents” a reference. You cannot take the address of the reference itself. If you do sizeof(T&), you will get the same answer as sizeof(T). So most accurately, a reference is an alias for the actual instance of an object. Because references are not true value types in and of themselves, but instead are aliases for the instance, they have the following semantics: They must be “bound” to an instance at initialization. A reference can never be “null.” They cannot be re-assigned. Assigning to a reference after it has been “bound” to an instance is equivalent to assigning to the bound instance, not the reference. Comparing references is equivalent to comparing the referenced instances. Taking the address of a reference gives the address of the bound instance. Implementations As discussed above, a pointer is an explicitly defined value type. They take up memory on the stack/heap. A reference, on the other hand, is not an explicitly defined value type. Because a reference isn’t a “real” value type, but instead defined as an alias to the bound instance, the compiler is free to implement references however it wants, as long as it maintains the semantics. This means a compiler is free to optimize out a reference completely. The compiler cannot inherently do this with a pointer: a pointer has to actually exist because you can take its address, reassign it, etc. However, the compiler is just as free to implement a reference as a pointer (in the machine sense, see below), and often will do so if the reference passes between functions that cannot be inlined. Why is this so confusing? Two reasons: Conflating Pointer with Indirect Referencing When people talk about pointers, they often use them interchangeably with the machine’s notion of a memory address and indirect referencing, because that’s what a (raw) pointer models. But these are actually two distinct things. Pointer the C/C++ type is an abstract notion of a memory address that can be used for indirect referencing. It has meaning independent from how a particular platform implements indirect referencing; there is no “pointer” type in assembly, just instructions that perform operations indirected through a memory address. So when folks say “a reference and a pointer are the same thing” they are thinking in terms of this generated machine assembly for indirect referencing, and how the generated assembly might store the addresses used for it. The “Reference Semantics” Colloquialism There is a common colloquialism to refer both pointers and references as having “reference semantics.” What people mean when they say this is that a given variable name is indirectly representing an instance, without being a value type of that instance. It allows manipulation of the instance through the variable name, and passing the instance between functions without having to copy it. However this colloquialism is a misnomer. A pointer does not, in fact, have reference semantics. It is a value type. It is that value type which models reference semantics, through the * and -> operators. You’ll often hear this pointed out by folks when they ask “does Python/Java have reference semantics or value semantics?” It’s a trick question: the correct answer is “they have value semantics, but the only value type you can directly assign to a name is a pointer.” That said, the lack of a true reference, or an assignable value type other than a pointer, is key to understanding why Java and Python behave the way they do.
🌐
DEV Community
dev.to › jayaprakash20 › pointers-vs-references-a-deep-dive-into-c-fundamentals-4024
Pointers vs References: A Deep Dive into C++ Fundamentals - DEV Community
July 27, 2025 - They're part of the C++ Standard Library (since C++11) and live in the <memory> header. ... Owns a resource exclusively (no other pointer can point to it). Automatically deletes the object when it goes out of scope. ... Allows multiple pointers to share ownership of a dynamically allocated object. Internally uses reference counting.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › article › when-to-use-references-vs-pointers-in-c-cplusplus
When to use references vs. pointers in C/C++
March 15, 2026 - In C programming, we work with pointers to access memory addresses and manipulate data indirectly. C does not have reference variables like C++, but understanding the difference helps when transitioning between languages.
🌐
Codefinity
codefinity.com › blog › References-vs-Pointers-in-C-plus-plus
References vs Pointers in C++
Learn about the differences between pointers and references in C++. Pointers store memory addresses and allow for memory manipulation, while references act as aliases for variables, promoting cleaner code.
🌐
UTK
web.eecs.utk.edu › ~bmaclenn › Classes › 102-S10 › thinkCScpp › chap16.htm
Chapter 16: Pointers and References
When declaring a pointer to an object or data type, you basically follow the same rules of declaring variables and data types that you have been using, only now, to declare a pointer of SOMETYPE, you put an asterisk * in front of the variable: SOMETYPE* somevar; int* x; To declare a reference, you do the exact same thing you did to declare a pointer, only this time, rather than using an asterisk *, use instead an ampersand &: SOMETYPE& somevar; int& x; This is most commonly used for reference parameters (Section 8.7), but as you will learn in a moment, there are also reference variables.
🌐
Test-king
test-king.com › blog › understanding-the-differences-between-pointers-and-references-in-c
differences between pointers and references in C
References, on the other hand, act as aliases for existing variables. Once a reference is bound to a variable, it cannot be changed to refer to another variable. References provide a safer and more user-friendly interface to variables and are particularly useful when passing large objects to ...
🌐
W3Schools
w3schools.com › c › c_pointers.php
C Pointers
Use the & operator to store the memory address of the myAge variable, and assign it to the pointer. Now, ptr holds the value of myAge's memory address. In the example above, we used the pointer variable to get the memory address of a variable (used together with the & reference operator). You can also get the value of the variable the pointer points to, by using the * operator (the dereference operator):
🌐
TutorialsPoint
tutorialspoint.com › article › explain-reference-and-pointer-in-c-programming
Explain reference and pointer in C programming?
March 15, 2026 - C has no references − only pointers for indirect access ... Pointers are fundamental in C for dynamic memory allocation, function parameters, and efficient data manipulation.
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_pointers.htm
Pointers in C
The only difference between pointers of different data types is the data type of the variable or constant that the pointer points to. After declaring a pointer variable, you need to initialize it with the address of another variable using the ...
🌐
Codecademy
codecademy.com › learn › learn-c-plus-plus › modules › learn-cpp-references-and-pointers › cheatsheet
Learn C++: References & Pointers Cheatsheet | Codecademy
In C++, pass-by-reference with ... computational cost of making a copy of the argument. ... In C++, a pointer variable stores the memory address of something else....
🌐
GeeksforGeeks
geeksforgeeks.org › c language › c-pointers
Pointers in C - GeeksforGeeks
A pointer is a variable that stores the memory address of another variable. Instead of holding a direct value, it holds the address where the value is stored in memory. It is the backbone of low-level memory manipulation in C. A pointer is declared ...
Published   April 22, 2026
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › pointers-and-references-in-c
Pointers and References in C++ - GeeksforGeeks
2 weeks ago - Pointers store memory addresses and provide indirect access to data. References create an alternative name for an existing variable.
🌐
DEV Community
dev.to › zigrazor › pointer-vs-reference-in-c-the-final-guide-3475
Pointer vs Reference in C++: The Final Guide - DEV Community
September 1, 2021 - A pointer has its own memory address and size on the stack whereas a reference shares the same memory address (with the original variable) but also takes up some space on the stack.
🌐
Programiz
programiz.com › c-programming › c-pointer-functions
C Pass Addresses and Pointers to Functions
In this tutorial, you'll learn to pass addresses as arguments to the functions with the help of examples. This technique is known as call by reference.