[問題] 函數呼叫傳參數
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
以下是程式碼
#include <iostream>
using namespace std;
class stack
{
public:
int item[10];
int top;
void create(**);
void insert(*);
}
void stack::create(**s)
{
(*s)=new stack;
(*s)->top=-1;
}
void stack::insert(*s)
{
int a;
cout<<"請輸入一個數";
cin>>a;
s->top=++top;
s->item[top]=a;
}
void main()
{
stack *abc;
abc->create(&abc);
abc->insert(abc);
delete abc;
}
問題:
想請問各位大大,在main()中的
abc->create(&abc)、abc->insert(abc),這二行的語法
雖然程式是可以執行,但語法看起來就感覺有點奇怪
謝謝各位。
--
身念處,觀身不淨;受念處,觀受是苦;心念處,觀心無常;法念處,觀法無我。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.160.157.35
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1419465597.A.796.html
→
12/25 08:34, , 1F
12/25 08:34, 1F
推
12/25 08:40, , 2F
12/25 08:40, 2F
→
12/25 08:58, , 3F
12/25 08:58, 3F
→
12/25 09:07, , 4F
12/25 09:07, 4F
→
12/25 09:07, , 5F
12/25 09:07, 5F
→
12/25 10:44, , 6F
12/25 10:44, 6F
→
12/25 11:16, , 7F
12/25 11:16, 7F
→
12/25 11:19, , 8F
12/25 11:19, 8F
→
12/25 11:24, , 9F
12/25 11:24, 9F
→
12/25 11:47, , 10F
12/25 11:47, 10F
→
12/25 13:08, , 11F
12/25 13:08, 11F
推
12/25 13:23, , 12F
12/25 13:23, 12F
推
12/25 20:57, , 13F
12/25 20:57, 13F
→
12/25 20:58, , 14F
12/25 20:58, 14F
→
12/25 20:59, , 15F
12/25 20:59, 15F
→
12/25 21:00, , 16F
12/25 21:00, 16F
→
12/25 21:00, , 17F
12/25 21:00, 17F
→
12/25 21:01, , 18F
12/25 21:01, 18F
→
12/25 21:03, , 19F
12/25 21:03, 19F
→
12/25 21:04, , 20F
12/25 21:04, 20F
討論串 (同標題文章)