I doubt that the variable "some" in the first code is a variable, it wouldn't run when I try to declare a variable called some.
But your problem with this code...
struct MyStruct {
MyStruct(const int &value) {}
};
int main() {
std::string(s2);
MyStruct(some); // illegal now
std::cout << s2 << std::endl;
}
is that you don't have an identifier for the MyStruct that you are instantiating.
struct MyStruct {
MyStruct(const int &value) {}
};
int main() {
int some = 5;
std::string(s2);
MyStruct myStruct (some); // illegal now
std::cout << s2 << std::endl;
}
Here I placed "myStruct" as the identifier for the "MyStruct". I also declared a variable called "some" to check if it runs that way, which it does.