[ACCEPTED]-How do you make a prototype of a function with parameters that have default values?-c++
Accepted answer
You should put the default arguments in 7 the prototype, not the definition like this:
void arryprnt(int[] a, string intro, int len, string sep=", ", string end=".");
and 6 the make the definition without them:
void arryprnt(int[] a, string intro, int len, string sep, string end) {
// ...
}
BTW: on 5 another note. It is considered good practice 4 to pass objects which larger than an int 3 by const reference. While this isn't appropriate for all situations, it 2 is appropriate for most and avoids copying 1 things unnecessarily. For example:
void func(const std::string &s) {
// do some read-only operation with s.
}
func("hello world");
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.