implicit pointers?

Could someone please explain what an implicit pointer is, The book I am learning from (currently learning about returning references) says "When a function returns a reference, it returns a implicit pointer to its return value". I've tried looking this up but all I can find is stuff that either I dont think has anything to do with it, or it seems like it might be too advanced so I do not understand what it is talking about.

It sounds like the author misspoke. There's no such thing as an "implicit pointer". What the author meant was that references are more or less equivalent to pointers:
1
2
3
4
5
6
7
int &f(bool x){
    static int a = 1;
    static int b = 2;
    if (x)
        return a;
    return b;
}
which is functionally equivalent to
1
2
3
4
5
6
7
int *f(bool x){
    static int a = 1;
    static int b = 2;
    if (x)
        return &a;
    return &b;
}
Last edited on
"implicitly de-referenced pointers" are the basis of an awful analogy used to (badly) teach references.
Last edited on
"When a function returns a reference, it returns a (sic) implicit pointer to its return value".

It appears this quote comes from
https://tutorialink.com/cpp/return-by-reference.cpp

The statement and indeed the example are almost meaningless, definitely useless.

If there is an implicit pointer, it is 'this', hardly a sufficiently important revelation for anyone learning c++ to get side-tracked on.
It's misleading to think of a reference as an implicit pointer. References are sometimes implemented with a pointer, but a reference is not a pointer.

A reference is a synonym for an existing object. It lets you have two names for the same variable.
1
2
int x;
int &y{x);   // x and y refer to the same int 


You can't make a reference refer to a different object, just like you can't make a variable x refer to a different object either.
Topic archived. No new replies allowed.