About the order of input parameters

Viewed 6329

For a function/method contains many input parameters, does it make a difference if passing-in in different orders? If does, in what aspects (readability, efficiency, ...)? I am more curious about how should I do for my own functions/methods?

It seems to me that:

  1. Parameters passing by references/pointers often come before parameters passing by values. For example:

    void* memset( void* dest, int ch, std::size_t count ); 
    
  2. Destination parameters often come before source parameters. For example:

    void* memcpy( void* dest, const void* src, std::size_t count );
    
  3. Except for some hard constraints, i.e., parameters with default values must come last. For example:

    size_type find( const basic_string& str, size_type pos = 0 ) const;
    
  4. They are functional equivalent (achieve the same goal) no matter what order they pass in.

4 Answers
Related