I already know what the difference is but does anyone know a good way to memorize the difference between the two?
Printable View
I already know what the difference is but does anyone know a good way to memorize the difference between the two?
Hello E-man96,
That sounds like fun.
Hm, how about you look at the parameters as the Happy Meal and the arguments as what's in the bag? If there's no burger, fries, drink and pokemon action figure, then you know you didn't get the right meal.
Using the definitions from Stroustrup's C++ glossary:
argument - a value passed to a function or a template. In the case of templates, an argument is often a type.
parameter - a variable declared in a function or templates for representing an argument. Also called a formal argument. Similarly, for templates.
Sometimes "argument" is used in both cases, upon which "actual argument" means argument and "formal argument" means parameter. Likewise, sometimes "parameter" is used in both cases, upon which "actual parameter" means argument and "formal parameter" means parameter.
EDIT:
Okay, I did not read the question very carefully... but I personally find it easy to distinguish between the two after some practice. Often it does not matter anyway as the terms might be used interchangeably.
Although the term was used interchangeably but i think it is better to differentiate it.
Code:
void display(vector<int>&) --- Paramater
vector<int> vec;
display(vec); --- Argument
A simple way to remember is to look at the what the function(or anything else like a template, class..) requires and this is the "parameters" and what I will pass is the "arguments".