C++????Щ?£??????????
???????????? ???????[ 2014/5/14 13:12:53 ] ???????????????? net
??????????????
??????????C++?п??????????????????????????壬?????????????????????????????????????????????????????????巋????????????????á???????????????????????????в??????????????????????????????????????????????????????????????Щ????
????????????????
???????????????????????????????βΣ???????ú????????????????Ρ?????????β???????????м????????????????
????1?????????β?
????1???????????????
???????????????????????????????????????βε?????????????ε??????????β????????????з???????????????ε????????????????????ε???????????????????????????
void swap(int v1?? int v2)
{
int temp = v1;
v2 = v1;
v1 = temp;
}
swap(a?? b);// ????swap
|
????????????У?????a??b??????????????v1??v2???????a??b????????????????a??b?????б仯??
????2??????β?
???????????βο???????????????????????????????1?????????????????????????ε???????????????????????????????????????????????
void swap(int* v1?? int* v2)
{
int temp = *v2;
*v2 = *v1;
*v1 = temp;
}
int main()
{
int a = 10??b = 20;
int *p1 = &a??*p2 = &b;
swap(p1??p2);
return 0;
}
|
????????????ж????swap???β??????????main?е???swap???????swap????????p1??p2?????????????????????????
????3??const ?β?
????????????????????????const???????????????????????????????????????ε?????????????壬????б??????????const????壬?????????int???
????void fcn(const int i);
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11