Is it possible for an overloaded constructor to somehow call another constructor within the class, similar to the code below?
class A {
public:
A(std::string str) : m_str(str) {}
A(int i) { *this = std::move(A(std::to_string(i))); }
std::string m_str;
};
The code above works, yet I am afraid that calling this in the constructor might lead to undefined behavior.
If it does could you please explain why and also suggest a better alternative?