you just sent an explanation for the warning, what do you not understand?
the warning is for this code, but i want to know why i get that warning? and should use std::move()
the picture you sent explains why you get the warning. you make a copy of the parameter, and then copy it again to firstname. why do you need this double copy? you can either make the parameter a reference, so you won't copy the parameter, or use std::move, so you'll take advantage of the move semantics to "steal" what you can from the parameter instead of copying the whole string twice. personally, in this case I'll make the parameter a reference, there's no reason to use move semantics here.
should i write const string &fname?
Обсуждают сегодня