Passing two parameters: one by const ref. and another by ref.

Mar 30, 2014 at 5:32am
Is it okay to pass two parameters to a function with one by constant referecne and the other by reference?

 
  void getUniqueIP(const vector<string>& refIP, vector<string>& refUniqueIP)
Mar 30, 2014 at 5:38am
Yes.

Prefer 'reference to const T' over 'constant reference to T'.

Consider rewriting the function as:

std::vector<std::string> getUniqueIP( const std::vector<std::string>& refIP ) ;

See: http://joseluisestebanaparicio.blogspot.in/2010/06/want-speed-pass-by-value.html
Last edited on Mar 30, 2014 at 5:47am
Topic archived. No new replies allowed.