Thoughts on using "const (class)&" parameters where "const (class)" would be used?

From: Ken Overton (ken.overton_at_gmail.com)
Date: 10/08/04


Date: Fri, 08 Oct 2004 13:22:26 GMT


For example, STL strings, which I use all over the place. Instead of doing:

void MyClass::MyMethod(const std::string param) {...}

I kind of like doing:

void MyClass::MyMethod(const std::string& param) {...}

What I like is that I avoid the overhead of making copies on the stack
everywhere, but to be honest the real reason I've been doing it is
because I'm sick of stepping into the STL code in the debugger when I'm
really trying to step into MyMethod (yeah, I know, that's a pretty lousy
reason).

Is there anything egregious about this kind of usage?

-- kov