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() // w w  w .  ja va  2  s  .  c  o m
{ 
    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