Please, what is the difference between this
void func(std::string *_str) {
*_str = "hello";
}
void main() {
std::string s;
func(&s);
std::cout << s << "n";
}
where I pass a pointer to the string into which I copy the data…
and that:
std::string func2() {
return "hello2";
}
void main() {
std::string s = func2();
std::cout << s << "n";
}
where the function returns data.
In both cases, do I end up copying the data right?
1