Changing variable types after initialization C++
<p>I'm coming from node.js and I was wondering if there is a way to do this in C++. What would be the C++ equivalent of:</p>

<pre><code>var string = "hello";
string = return_int(string); //function returns an integer
// at this point the variable string is an integer
</code></pre>

<p>So in C++ I want to do something kind of like this...</p>

<pre><code>int return_int(std::string string){
     //do stuff here
     return 7; //return some int
}
int main(){
    std::string string{"hello"};
    string = return_int(string); //an easy and performant way to make this happen?
}
</code></pre>

<p>I'm working with JSON and I need to enumerate some strings. I do realize that I could just assign the return value of <code>return_int()</code> to another variable, but I want to know if it's possible to reassign the type of variable from a string to an int for sake of learning and readability.</p>