<<<    Index     Address of a C++ variable >>>

1. Properties of a C++ variable

  • Consider:

    
    int main( )
    {
        // Local variables:
        int x = 5;
        double d = 0.1;
    
        // Variable sizes:
        int x_bytes = sizeof( x );
        int d_bytes = sizeof( d );
    
        // What about variable addresses ?
        int x_addr = addressof( x );
        int d_addr = addressof( d );
    
        return 0;
    }
    
    
  • Note: this sample will not yet compile because of the addressof.

  • What do we know about x and d?

    • Types are int and double

    • Operator sizeof returns sizes in bytes

    • How about an address of a variable?

<<<    Index     Address of a C++ variable >>>