8.1 地址运算符(指针是存储内存地址的变量)

Posted: March 25, 2011 in C++

/*
非常重要的一句话:
指针是存储内存地址的变量. 相当于门牌号.

通过地址运算符&, 可以知道变量在内存中的地址, 找到门牌号.
*/

#include <iostream>

using namespace std;

void main()
{
           int a=100;
           float b=3.6f;

           cout<<“a=”<<a<<” address of RAM: “<<&a<<endl;
           cout<<“b=”<<b<<” address of RAM: “<<&b<<endl;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s