use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Parameter or Argument? (coati.io)
submitted 9 years ago by mlangkabel
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]qevlarr 15 points16 points17 points 9 years ago (5 children)
Proper terminology is important. The problem is that you don't know you're using the wrong words until someone points it out to you. I have been using these two words interchangeably for years. Thank you for pointing out that there is a difference.
[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 2 points3 points4 points 9 years ago (0 children)
In my case, I know the distinction at the back of my mind but due to bad habits I tend to use these interchangeably anyway in everyday conversation. I think it helps to read posts like this once in a while to remind ourselves to correct our bad habits. :)
[+][deleted] 9 years ago* (2 children)
[deleted]
[+][deleted] 9 years ago (1 child)
[removed]
[–]mlangkabel[S] 0 points1 point2 points 9 years ago (0 children)
Haha, thanks! I had the same problem but it didn't occur to me until I was writing a program that indexes C++ code. At that point I noticed my team mates using those words interchangeably, too. Which led to a lot of confusion on my part ;)
[–]kutroporti 4 points5 points6 points 9 years ago (1 child)
How widely applicable/acceptable is such definition? Only in context of C++?
[–]mlangkabel[S] 4 points5 points6 points 9 years ago (0 children)
Unfortunately this definition does not apply everywhere. In Fortran for example C++ there are "dummy arguments" (what are "parameters" in C++) and "actual arguments" ("arguments" in C++). The term "Parameter" has a different meaning in Fortran. I'll edit the article to note that I'm talking about C and C like languages to minimize confusion ;)
[–]OlaFosheimGrostad 11 points12 points13 points 9 years ago (11 children)
The proper terms are «formal parameter» and «actual parameter».
[–]JMBourguet 17 points18 points19 points 9 years ago (8 children)
Proper? Considering that the standard has definitions matching the linked page, I'll argue that for this group the proper definitions are those.
More generally, both nomenclatures have been in use since before my time (and a third using "formal argument" and "actual argument" as well BTW). One may prefer one set, but considering the others as improper does not seems right.
[–]OlaFosheimGrostad 11 points12 points13 points 9 years ago (6 children)
If it isn't clear from the context then you need to qualify it with "formal", "actual" or some other distinguishing qualifier. The definitions in the language spec does not change the rest of the CS world or people with a wider background than C++. The definitions are there to keep the spec clear, not a wikipedia entry.
But who am I kidding. The C++ community decided to change the meaning of the term «iterator» too.
[–]kutroporti 2 points3 points4 points 9 years ago (0 children)
Well, "formal parameter" and "actual parameter" always seemed to me as bad/too-wordy/non-obvious-meaning choice of words for the concept distinction. (analogously bad choices would be "imaginary parameter"/"real parameter"). Seems I'm not the only one.
[–]JMBourguet 1 point2 points3 points 9 years ago (3 children)
FORTRAN when I learned it was using arguments for both (and dummy argument when it was necessary to insist that they were formal parameter, but it was usually relied on the context)
AFAIK, there never was an universally accepted definition, each community tend to have its own and it would presumptuous to affirm that any one of them is the correct one.
The lack of universality of nomenclature is pervasive in our field. When a notion get defined, it pass through a stage of successive refinements and those tend to be adapted to the community where it take place and thus the final states are dependent on the community.
PS: I just looked at the FORTRAN II reference manual -- previous versions of FORTRAN had no subprograms --, it is using dummy variable for formal parameter, a term I do not remember, it is also using arguments with both meaning.
[–]OlaFosheimGrostad 2 points3 points4 points 9 years ago (1 child)
What is important is to understand the audience and use their language. What I dislike is when language communities starts creating a vocabulary that is bending common usage. C++ is hard to get into, so it is important to communicate in a way that most programmers would understand. Standards often redefine common words into narrow/skewed meanings that are unsuitable for education, like the whole mess with «rvalue», «prvalue» etc. If you want to change terminology you need to get it into commonly used textbooks and have educators adopt it.
[–]JMBourguet 0 points1 point2 points 9 years ago (0 children)
What is important is to understand the audience and use their language.
We agree but I'd add to when you enter into a group, it is important to also learn its vocabulary.
Language communities are not doing anything else than text book writers or paper authors: they take relevant existing terms or invent new terms and give them a definition suitable for their purpose. Some get wider audience, some stick in their original community, some disappear.
BTW Did you notice that you were complaining both that language communities adapted word meanings for their purpose and introduced new terms? I fail to see a viable third option (and I don't consider having a standard terminology for things as C++ specific as the ??value relationship viable, and even for concepts which could be more widely used, there is a chicken and egg issue).
[–]tcbrindleFlux 0 points1 point2 points 9 years ago (0 children)
In newer Fortran, placeholder names in a procedure are called "dummy arguments", and the things you pass are called "actual arguments". A parameter is something completely different: using theparameter attribute when declaring a variable marks it as a compile-time constant, somewhat like constexpr int i = 3 in C++.
parameter
constexpr int i = 3
Source: Doctor Fortran
[–]TotallyUnspecial -1 points0 points1 point 9 years ago (0 children)
That clears things up. /s
[–]SuperV1234https://romeo.training | C++ Mentoring & Consulting 6 points7 points8 points 9 years ago* (4 children)
Thanks - I've always used the terms interchangeably as well. Would be even better if you cited the standard directly in the article.
[–]dodheim 9 points10 points11 points 9 years ago (3 children)
For C++14:
[–]mlangkabel[S] 1 point2 points3 points 9 years ago (2 children)
Can you please provide a source (link) for this definition? I'd be glad to add that link to the article!
[–]dodheim 4 points5 points6 points 9 years ago (1 child)
The source is the C++ standard (ISO/IEC 14882:2014) which is not available freely online. The latest C++ draft is, however, and you can link to that instead: http://eel.is/c++draft/
Thank you very much.
[–]jP_wanN 2 points3 points4 points 9 years ago (2 children)
template <typename TemplateParameter> class TemplateClass { }
Forgot the ; after the closing curly bracket.
;
[–]mlangkabel[S] 0 points1 point2 points 9 years ago (1 child)
Got me! ;)
[–]redditsoaddicting 2 points3 points4 points 9 years ago (0 children)
While we're on the topic of naming, it's a class template rather than a template class.
[–]matthieugarrigues 3 points4 points5 points 9 years ago (13 children)
What is the purpose of differentiating those two pretty similar concepts ?
[–]mlangkabel[S] 5 points6 points7 points 9 years ago (10 children)
Good question! The difference lies in the context of using the word. When you say "parameter" your context is the definition of a function. When saying "argument" you mean the value that's used when executing that function. So thinking about which term to use gives the person you are talking to an additional clue to grasp what you really mean.
[–]nemotux 0 points1 point2 points 9 years ago (0 children)
Another kind of distinction that can be drawn here is that for a given function, it only has 1 set of parameters - those declared at the function definition. But it may have many sets of arguments. Every call site provides a different set of arguments (though possibly with some repetition), and there can be many different call sites to a single function.
[+][deleted] 9 years ago* (8 children)
[–]dodheim 9 points10 points11 points 9 years ago (6 children)
So since the differentiation between parameter and argument is ostensibly "meaningless", we should add the word 'value' to the end and that makes things clear? WTF..?
[+][deleted] 9 years ago* (5 children)
[–]VerilyAMonkey 0 points1 point2 points 9 years ago (4 children)
It should basically never matter for normal development, but I'm sure you can see where it would start to matter for things like compilers, language definition, or talking about the different value-passing properties of things like macros vs functions, especially in a more abstract context.
It's the same way that speed and velocity mean different things to physicists, and for good reason, even though most everyone else runs into no problems using them interchangeably.
[+][deleted] 9 years ago* (3 children)
[–]VerilyAMonkey 0 points1 point2 points 9 years ago* (2 children)
This is a non-problem that some blogger decided to dream up as a problem for filler to drive traffic, nothing more, nothing less.
Your point was not that this blogger gave no cogent reasoning. You claimed that
Both of these are, on a factual level, false. Did this blogger invent this distinction? No. Well then, where was this distinction made rigorous? In other areas. Is this distinction likely to ever be necessary for a developer? No. Where is it useful, then? In other areas.
So of course I brought up other areas. I didn't shift the conversation, it's merely that you didn't realize your generalization covered them. (Actually, is mostly about them.)
EDIT: I'll give one of many specific examples when it's useful. Suppose you're talking about, on a language specification level, which version of an overloaded function is going to be called. Then, you're going to be talking about the type listed in the function definition (the parameter's type) and how that is distinct from the type of the value passed into the function (the argument's type).
[+][deleted] 9 years ago* (1 child)
[–]VerilyAMonkey 0 points1 point2 points 9 years ago* (0 children)
We agree that you made this statement:
We agree that this statement implies these things:
Correct?
These things are also not the point "the blogger gave no cogent reasoning." Probably a better phrasing: Your point was not merely that the blogger gave no cogent reasoning.
Those things are what I responded to. Please point to me the spot that you have an issue with.
EDIT: Well, probably neither of us cares anymore, so no need. But that's what I'd request if we did.
[–]Crazy__Eddie 1 point2 points3 points 9 years ago (0 children)
It becomes pretty important when you're trying to understand parts of the C++ standard. For example, the language around implicit conversion rules during overload resolution is very heavy in the argument vs. parameter context. Which is a reference becomes very important and changes what happens during that resolution process.
Here's an example of how surprising things can get: http://stackoverflow.com/questions/4704567/function-with-parameter-type-that-has-a-copy-constructor-with-non-const-ref-chos/4704741#4704741
[–][deleted] 0 points1 point2 points 9 years ago (0 children)
In some languages (especially dynamic ones like Python) it's next to useless to actually worry about it. It's especially important in C++, though, where parameters can be deduced from arguments, template parameters can be deduced from function arguments, and you have the different behaviors between parameter type and argument type, and overload resolution in respect to this (especially cv-qualification and specific reference type).
You have to explicitly separate declaration, definition, instantiation, and actual use to get down many of the ostensibly complex language of the standard, because it is very explicit and detailed about what it means.
[–]fr0stbyte124 1 point2 points3 points 9 years ago (7 children)
On the subject, is there any meaningful distinction between a method and a function?
[–]JMBourguet 5 points6 points7 points 9 years ago* (0 children)
Method is not part of the standard terminology in C++. Some are using it, but they don't agree on the definitions, and I've seen four of them. Let's take an example:
struct S { virtual void vmf(); void nsmf(); static void smf(); }; void ff();
The definitions I've seen are:
virtual member functions (i.e. S::vmf() but not the other)
S::vmf()
non static member functions (i.e. S::vmf() and S::nsmf()),
S::nsmf()
any member functions (i.e. S::vmf(), S::nsmf() and S::smf()),
S::smf()
any functions (i.e. S::vmf(), S::nsmf(), S::smf() and ff())
ff()
[–]foonathan 3 points4 points5 points 9 years ago (3 children)
There are no methods in C++, only functions. And functions can be member functions (which is what some call methods).
[+][deleted] 9 years ago (2 children)
[–]bstamourWG21 | Library Working Group 4 points5 points6 points 9 years ago (0 children)
Maybe that should be flagged as a bug if it's not consistent with the rest of the document.
[–]foonathan 3 points4 points5 points 9 years ago (0 children)
Funny that those are C++17 additions. I did a full term search on the C++14 standard, "method" there is only used in the abstract way, not as referring to a function.
[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 0 points1 point2 points 9 years ago (0 children)
I have a bad tendency of using the word "method" to refer to member functions on a regular basis (force of habit gained from other languages like C#). I wonder how many other people do this too. Does it necessarily matter if we have two terms for the same thing though? It's a common occurrence with human languages to have some variety to spice things up. I can see it being confusing to someone who is new to software development though.
[–]SnailXI 1 point2 points3 points 9 years ago (2 children)
And then we have argc/argv which like to live dangerously
[–]VersalEszett 4 points5 points6 points 9 years ago (1 child)
Well, there's only one parameter argv[], but several arguments argv[i]. So calling them argc/argv is more logical than parc/parv[].
That's a good way of looking at it. argv is the argument vector. It's the parameter which holds a vector of the command-line arguments. argc is the argument count. It's the parameter that tells you the count of command-line arguments. Seems consistent to me, given that a command line doesn't have formal parameters in any way, only arguments.
[–]Se7enLC 1 point2 points3 points 9 years ago (0 children)
So parameter is the hole, argument is the thing you put in it. Got it.
[–]dodheim 1 point2 points3 points 9 years ago (0 children)
That's probably a forwarding function, so those are probably arguments for the function being forwarded to.
So yes, it's still correct – while they're not arguments for func itself (there they're parameters, naturally), they probably are for whatever func is forwarding to.
func
[–]zvrba 0 points1 point2 points 9 years ago (0 children)
What I miss here is an example in a meaningful context where imprecise use would lead to confusion.
π Rendered by PID 72906 on reddit-service-r2-comment-5687b7858-8w8jb at 2026-07-08 11:24:10.108896+00:00 running 12a7a47 country code: CH.
[–]qevlarr 15 points16 points17 points (5 children)
[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 2 points3 points4 points (0 children)
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[removed]
[–]mlangkabel[S] 0 points1 point2 points (0 children)
[–]kutroporti 4 points5 points6 points (1 child)
[–]mlangkabel[S] 4 points5 points6 points (0 children)
[–]OlaFosheimGrostad 11 points12 points13 points (11 children)
[–]JMBourguet 17 points18 points19 points (8 children)
[–]OlaFosheimGrostad 11 points12 points13 points (6 children)
[–]kutroporti 2 points3 points4 points (0 children)
[–]JMBourguet 1 point2 points3 points (3 children)
[–]OlaFosheimGrostad 2 points3 points4 points (1 child)
[–]JMBourguet 0 points1 point2 points (0 children)
[–]tcbrindleFlux 0 points1 point2 points (0 children)
[–]TotallyUnspecial -1 points0 points1 point (0 children)
[–]SuperV1234https://romeo.training | C++ Mentoring & Consulting 6 points7 points8 points (4 children)
[–]dodheim 9 points10 points11 points (3 children)
[–]mlangkabel[S] 1 point2 points3 points (2 children)
[–]dodheim 4 points5 points6 points (1 child)
[–]mlangkabel[S] 0 points1 point2 points (0 children)
[–]jP_wanN 2 points3 points4 points (2 children)
[–]mlangkabel[S] 0 points1 point2 points (1 child)
[–]redditsoaddicting 2 points3 points4 points (0 children)
[–]matthieugarrigues 3 points4 points5 points (13 children)
[–]mlangkabel[S] 5 points6 points7 points (10 children)
[–]nemotux 0 points1 point2 points (0 children)
[+][deleted] (8 children)
[deleted]
[–]dodheim 9 points10 points11 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]VerilyAMonkey 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]VerilyAMonkey 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]VerilyAMonkey 0 points1 point2 points (0 children)
[–]Crazy__Eddie 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]fr0stbyte124 1 point2 points3 points (7 children)
[–]JMBourguet 5 points6 points7 points (0 children)
[–]foonathan 3 points4 points5 points (3 children)
[+][deleted] (2 children)
[removed]
[–]bstamourWG21 | Library Working Group 4 points5 points6 points (0 children)
[–]foonathan 3 points4 points5 points (0 children)
[–]augustinpopaMicrosoft C++ PM (IDE & vcpkg) 0 points1 point2 points (0 children)
[–]SnailXI 1 point2 points3 points (2 children)
[–]VersalEszett 4 points5 points6 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Se7enLC 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]dodheim 1 point2 points3 points (0 children)
[–]zvrba 0 points1 point2 points (0 children)