Cpp - Using the Address of Operator on References

Introduction

If you ask a reference for its address, it returns the address of its target.

Demo

#include <iostream> 
 
int main() //  ww w  .  java2  s .  c  om
{ 
    int  intOne; 
    int &rSomeRef = intOne; 
 
    intOne = 5; 
    std::cout << "intOne: " << intOne << std::endl; 
    std::cout << "rSomeRef: " << rSomeRef << std::endl; 
 
    std::cout << "&intOne: "  << &intOne << std::endl; 
    std::cout << "&rSomeRef: " << &rSomeRef << std::endl; 
 
    return 0; 
}

Result

Related Topic