摘要: 1voidout(char*ch,inti)2{3cout<<ch<<","<<i<<endl;4}56intmain()7{8vector<char*>vec;9vec.push_back("str1");10vec.push_back("str2");1112inti=0;13out("---begin---",i);1415while(i<vec.size())16{17out(vec[i],i++);18}1920out("---- 阅读全文
posted @ 2011-05-16 20:30 AnnieKim 阅读(678) 评论(1) 推荐(0) 编辑
摘要: void func(int *ptr, int &value){ ptr = &value; }int main(){ int i = 10, j = 5; int *ptr = &i; func( ptr, j); printf("%d", *ptr); return 0;}请问,此时输出来的*ptr的值是多少?5还是10?答案是10。这里主要涉及到函数参数问题,同int类型一样,指针也存在引用的问题。如果上面的函数声明改为:void func (int* &ptr, int &value);则答案就是5了。 阅读全文
posted @ 2011-05-16 09:23 AnnieKim 阅读(719) 评论(1) 推荐(3) 编辑