欢迎来到天天文库
浏览记录
ID:37866023
大小:715.83 KB
页数:14页
时间:2019-06-01
《CHAPTER 5 Input 4. Pointing Devices课件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、CHAPTER5InputPointingDevicesPointersApointerisavariableusedtostoretheaddressofamemorycell.Wecanusethepointertoreferencethismemorycell100……1024…Memoryaddress:10241032…1020integerpointerPointerTypesPointerC++haspointertypesforeachtypeofobjectPointerstointobjectsPointerstocharobjec
2、tsPointerstouser-definedobjects(e.g.,RationalNumber)EvenpointerstopointersPointerstopointerstointobjectsPointerVariableDeclarationofPointervariablestype*pointer_name;//ortype*pointer_name;wheretypeisthetypeofdatapointedto(e.g.int,char,double)Examples:int*n;RationalNumber*r;int**
3、p;//pointertopointerAddressOperator&The"addressof"operator(&)givesthememoryaddressofthevariableUsage:&variable_name100…………Memoryaddress:1024inta=100;//getthevalue,cout<4、020b#includeusingnamespacestd;voidmain(){inta,b;a=88;b=100;cout<<"Theaddressofais:"<<&a<5、sPointerVariables10088…1024…Memoryaddress:10241032…1020apinta=100;int*p=&a;cout<6、errorint*p;p=0;cout<7、alPointerUsagevoidIndirectSwap(char*Ptr1,char*Ptr2){chartemp=*Ptr1;*Ptr1=*Ptr2;*Ptr2=temp;}intmain(){chara='y';charb='n';IndirectSwap(&a,&b);cout<8、nterconstant#includeusingnamespacestd
4、020b#includeusingnamespacestd;voidmain(){inta,b;a=88;b=100;cout<<"Theaddressofais:"<<&a<5、sPointerVariables10088…1024…Memoryaddress:10241032…1020apinta=100;int*p=&a;cout<6、errorint*p;p=0;cout<7、alPointerUsagevoidIndirectSwap(char*Ptr1,char*Ptr2){chartemp=*Ptr1;*Ptr1=*Ptr2;*Ptr2=temp;}intmain(){chara='y';charb='n';IndirectSwap(&a,&b);cout<8、nterconstant#includeusingnamespacestd
5、sPointerVariables10088…1024…Memoryaddress:10241032…1020apinta=100;int*p=&a;cout<6、errorint*p;p=0;cout<7、alPointerUsagevoidIndirectSwap(char*Ptr1,char*Ptr2){chartemp=*Ptr1;*Ptr1=*Ptr2;*Ptr2=temp;}intmain(){chara='y';charb='n';IndirectSwap(&a,&b);cout<8、nterconstant#includeusingnamespacestd
6、errorint*p;p=0;cout<
7、alPointerUsagevoidIndirectSwap(char*Ptr1,char*Ptr2){chartemp=*Ptr1;*Ptr1=*Ptr2;*Ptr2=temp;}intmain(){chara='y';charb='n';IndirectSwap(&a,&b);cout<8、nterconstant#includeusingnamespacestd
8、nterconstant#includeusingnamespacestd
此文档下载收益归作者所有