將函數內部的參數作爲參數傳遞並將函數聲明塊中的參數聲明爲函數定義中的變量之間有什麼區別?參數傳遞與變量聲明
示例:利用我的意見獲得問題的要點。
#include<iostream>
int max=0;
int t=0;
class stack
{
int s[10];
public:
void push(int);
void pop();
};
void stack::push(int y) //argument passed inside function parameter
{
if(t<=max);
{
s[t]=y;
t=t+1;
}
else
cout<<"Stack overflow";
}
void stack::pop()
{
int item; //variable declared inside function definition
if(t>=0)
{
t=t-1;
item=s[t+1];
}
}
我不清楚你在問什麼。你能舉出你提到的兩種情況的代碼嗎? – 2014-10-11 02:26:33
「收納任何美元硬幣的自動售貨機的投幣口」和「投擲硬幣」的區別是什麼... – deviantfan 2014-10-11 02:29:34
您是否在談論K&R參數聲明風格?那麼爲什麼這個問題被標記爲C++? C++從未接受過這種風格。 – 2014-10-11 02:57:52