C
本帖最后由 康小泡 于 2018-10-30 10:41 编辑typedef struct{
Elemtype *base;
Elemtype *top;
int size;
}sqstack;
status initstack(sqstack &s);
status gettop(sqstack s,Elemtype &e);
status push(sqstack &s,Elemtype e);
status pop(sqstack &s,Elemtype &e);
谁能告诉我加上&有什么作用,为什么有的要加有的不用加 你这个是 C++,不是 C 喔。& 是引用型,如果要改变传参就用,没有改变传参就不用
比如说 swap(int &x, int &y) ----> 调用时 swap(a,b)
C++
claws0n 发表于 2018-10-28 14:12你这个是 C++,不是 C 喔。& 是引用型,如果要改变传参就用,没有改变传参就不用
比如说 swap(int &x, i ...
那为什么push那个子函数有个没加啊,和gettop加了 gettop只是读取,Push是压入 xxx999 发表于 2018-10-28 14:19
那为什么push那个子函数有个没加啊,和gettop加了 gettop只是读取,Push是压入
压栈而已,只是添加在后面而已,传参 e 可以不是任何变量,但是改变了栈 s 这是C艹里面的引用啊
页:
[1]