Google C ++ Style Guide. Why is the I / O order?

In the Google C ++ Style Guide , he said:

When defining a function, the order of parameters: inputs, then outputs.

Basically, Google suggests arranging parameter settings, for example:

void foo(const Foo& input1, const Foo& input2, Foo* output);

However, my colleague suggested that the conclusion should be put in the first position. because in this way foo can take default values, and most of the time will not use the default value. eg:

void foo(Foo* output, const Foo& input1, const Foo& input2 = default);

I think he said it makes sense. Or is there something that we lack here in terms of readability, performance, ...? Why does the style guide suggest that the conclusion should be the last?

+4
source share
1

, Google, , :

https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Default_Arguments

, , . .

Pros

, , . . "" "".

, . , , . . , , -, , " " .

, () . , , , .

- ( ) .cc. , .

, . , .

.

// Support up to 4 params by using a default empty AlphaNum.
string StrCat(const AlphaNum &a,
              const AlphaNum &b = gEmptyAlphaNum,
              const AlphaNum &c = gEmptyAlphaNum,
              const AlphaNum &d = gEmptyAlphaNum);
+7

All Articles