//发现的一些以前没有注意到的现象。。。。
#include<iostream>
using namespace std;
void ref(char* (&ch)[3])
{
cout<<"ch:/t"<<ch<<endl;
cout<<"&ch:/t"<<&ch<<endl;
cout<<"&ch[0]:/t"<<&ch[0]<<endl;
}
void argu(char* ch[])
{
cout<<"ch:/t"<<ch<<endl;
cout<<"&ch:/t"<<&ch<<endl;
cout<<"&ch[0]:/t"<<&ch[0]<<endl;
}
int main(int argc,char* argv[])
{
char* ch[3];
ch[0]="abc";
cout<<"using reference:"<<endl;
ref(ch);
cout<<"using var argument:"<<endl;
argu(ch);
cout<<"original adress:"<<endl;
cout<<"ch:/t"<<ch<<endl;
cout<<"&ch:/t"<<&ch<<endl;
cout<<"&ch[0]:/t"<<&ch[0]<<endl;
cout<<"---------------------"<<endl;
int v[]={1,2,3};
int* vp=v;
int i=0;
int i1=1;
int* const cicp=&i;
// cicp=&i1;//l-value specifies const object
cout<<cicp<<endl;
cout<<&cicp<<endl;
/* int n=1;
int* pn=&n;
cout<<pn<<endl;
cout<<&pn<<endl;
cout<<n<<endl;
cout<<&n<<endl;
cout<<"---------------------"<<endl;
cout<<ip<<endl;
cout<<&ip<<endl; */
cout<<"---------------------"<<endl;
cout<<sizeof(vp)<<endl;
cout<<*vp<<endl;
cout<<vp<<endl;
cout<<&vp<<endl;
cout<<*&vp<<endl;
// cout<<*vp<<endl;
cout<<"---------------------"<<endl;
cout<<sizeof(v)<<endl;
cout<<*v<<endl;
cout<<v<<endl;
cout<<&v<<endl;
cout<<*&v<<endl;
cout<<"---------------------"<<endl;
cout<<v[0]<<endl;
cout<<&v[0]<<endl;
cout<<&v[1]<<endl;
return 0;
}
待续。。。。。。。。。