473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

What is the difference between argument and parameter in C++?

C++ standard says the following:

I am reading through c++ standard and have a difficulty understanding
the difference between these two terms.

Thanks,

puzzlecracker
Jun 27 '08 #1
5 6616
On Apr 14, 10:12*pm, puzzlecracker <ironsel2...@gmail.comwrote:
C++ standard says the following:

I am reading through c++ standard and have a difficulty understanding
the difference between these two terms.
argument refers to "formal parameter"
parameter refers to "actual parameter"

void f(int argument) {}

int main()
{
int parameter;
f(parameter);
}
template <class ArgumentType>
void f() {
}

int main()
{
typedef int ParameterType;
f<ParameterType>();
}
HTH.

--
Best Barry
Jun 27 '08 #2
Barry wrote:
On Apr 14, 10:12 pm, puzzlecracker <ironsel2...@gmail.comwrote:
>C++ standard says the following:

I am reading through c++ standard and have a difficulty understanding
the difference between these two terms.

argument refers to "formal parameter"
parameter refers to "actual parameter"
IME it's vice versa. IOW, 'argument' is a run-time thing, defined by
the _caller_. And 'parameter' is what the function has, internally;
it's more or less abstract.

If you replace 'parameter' with 'argument' and leave 'argument' as is,
you will get the normal C++ terminology.
>
void f(int argument) {}

int main()
{
int parameter;
f(parameter);
}
template <class ArgumentType>
void f() {
}

int main()
{
typedef int ParameterType;
f<ParameterType>();
}
HTH.
Turn it around and it should.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #3
On Apr 14, 10:23*pm, Barry <dhb2...@gmail.comwrote:
On Apr 14, 10:12*pm, puzzlecracker <ironsel2...@gmail.comwrote:
C++ standard says the following:
I am reading through c++ standard and have a difficulty understanding
the difference between these two terms.

argument refers to "formal parameter"
parameter refers to "actual parameter"

void f(int argument) {}

int main()
{
* *int parameter;
* *f(parameter);

}

template <class ArgumentType>
void f() {

}

int main()
{
* *typedef int ParameterType;
* *f<ParameterType>();

}

Sorry, by checking the standard, I got them reversed
:-)

Jun 27 '08 #4
On Apr 14, 10:32*pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Barry wrote:
On Apr 14, 10:12 pm, puzzlecracker <ironsel2...@gmail.comwrote:
C++ standard says the following:
I am reading through c++ standard and have a difficulty understanding
the difference between these two terms.
argument refers to "formal parameter"
parameter refers to "actual parameter"

IME it's vice versa. *IOW, 'argument' is a run-time thing, defined by
the _caller_. *And 'parameter' is what the function has, internally;
it's more or less abstract.

If you replace 'parameter' with 'argument' and leave 'argument' as is,
you will get the normal C++ terminology.


void f(int argument) {}
int main()
{
* *int parameter;
* *f(parameter);
}
template <class ArgumentType>
void f() {
}
int main()
{
* *typedef int ParameterType;
* *f<ParameterType>();
}
HTH.

Turn it around and it should.
As I recall that code
often written as

int main(int argc, char* argv[]);

template <class Arg>
void f(Arg arg) {}

which are kinda misleading in recalling the difference between
argument and parameter.

--
Best Regards
Barry
Jun 27 '08 #5
Barry <dh*****@gmail.comwrites:
As I recall that code
often written as

int main(int argc, char* argv[]);

template <class Arg>
void f(Arg arg) {}

which are kinda misleading in recalling the difference between
argument and parameter.

Yes. You should consider:

int fun(int x,int y);
sin(3,42);

The parameters of the function fun are x and y.

The arguments of the function call on the second line are 3 and 42.
The argument 3 is assigned to the parameter x, and the argument 42 is
assigned to the parameter y.
We need to distinguish these qualifiers, to talk unambiguously about calls such as:

int gcd(int x,int y){
return((x==y)
?x
:((x<y)
?gcd(x,y-x)
:gcd(y,x-y)));
}

Where we can say that in the last call to gcd, the argument y is
passed to the parameter x, and the argument x-y is passed to the
parameter y.
Of course, since main takes as parameters the arguments given to the
program, we can name a parameter argument.

int f(int argument){
return((argument==1)
?1
:((argument%1)
?f(3*argument)
:f(argument/2)));
}

So we can say that the argument argument/2 is passed to the parameter
argument.

--
__Pascal Bourguignon__
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: John M. Gabriele | last post by:
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
3
by: Brett | last post by:
What is the following code doing? I see evt and event but what is the difference? <input type="radio" id="us_countryFlag1" name="us_country" onclick="togglePurDec(event)">Yes <script>...
10
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the...
2
by: Alexander Fedin | last post by:
Guys, I 've met some strange behaviour of the C# compiler. To reproduce it please try to compile the code below and you 'll be really amazed. The problem is that you can not use an interface...
14
by: code break | last post by:
what is the difference in this pointers decalarition ? int *ptr; and int (*ptr);
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
0
by: Michael Rudolph | last post by:
Hi DB2 newsgroup, I have encountered a difference between our development DB2 on Windows and the test environment on AIX. If using the LOCATE scalar function with a SMALLINT as LENGTH parameter...
1
by: Mohammed Alamgir Hosen | last post by:
Hello It is my first question to you. I have a little confuse about the different between Parameter and Argument. I will very glad if you help me in this occasion.. Yuor's ever Alamgir
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.