T
Tomás
#include <string>
#include <iostream>
using std::cout;
using std::endl;
void FunctionThatModifies(std::string &a)
{
a = "You've been modified.";
}
int main()
{
std::string const a("Untouchable.");
std::string &b = a; //Actually compiles with error!
FunctionThatModifies(b);
std::cout << b;
}
Compiler gives me a warning. I think it should give me a downright error,
and I want it to give me a downright error.
Firstly, does the Standard say whether this should generate a warning or
an error?
Secondly, do compilers have an option whereby you can make it give an
error? If so, I'll be using it.
-Tomás
#include <iostream>
using std::cout;
using std::endl;
void FunctionThatModifies(std::string &a)
{
a = "You've been modified.";
}
int main()
{
std::string const a("Untouchable.");
std::string &b = a; //Actually compiles with error!
FunctionThatModifies(b);
std::cout << b;
}
Compiler gives me a warning. I think it should give me a downright error,
and I want it to give me a downright error.
Firstly, does the Standard say whether this should generate a warning or
an error?
Secondly, do compilers have an option whereby you can make it give an
error? If so, I'll be using it.
-Tomás