sinemakinci1 / Cpp-Copilot-VSC-Demo

0 stars 0 forks source link

Should `std::move` strings into members #12

Open TartanLlama opened 2 months ago

TartanLlama commented 2 months ago

https://github.com/sinemakinci1/Cpp-Copilot-VSC-Demo/blob/9db124b0e801cfc5331261c1867d0d7e1fa4f6c6/src/user.cpp#L8

Since you take the std::string by value, you should std::move it into storage, like this->name = std::move(name);.

I assume you're using these getters and setters for something in your demo? Generally getters and setters like this are not recommended unless there's some class invariant that they're upholding.

sinemakinci1 commented 2 months ago

@TartanLlama we are not using tem for something beyond asking users to enter a name and then using that name to output info. What would be recommended here?

TartanLlama commented 2 months ago

Just a public member is fine