I'm trying to convert a number to a string then back to a number to perform math, then back to a string to return it to the user. I don't understand the problem because this is how my friend did it (that I can remember and it worked for him). Basically if someone can help me with this topic it would be apreciated!
std::string Resistor::CalculateResistance(int Digit1, int Digit2, int Multiplier, int Tolerance) {
std::istringstream buffer;
buffer >> Digit1;
std::string x = buffer.str; // Problem
buffer >> Digit2;
x += buffer.str; // Problem
double y = atof(x.c_str) * Multiplier; // Problem
std::istringstream buffer2;
std::string z = "";
if (y > 999 && y < 999999) {
y /= 1000;
buffer2 >> y;
z = buffer2.str + "KΩ" + Tolerances[Tolerance]; // Problem
return z;
}
else if (y > 999999 && y < 999999999) {
y /= 1000000;
buffer2 >> y;
z = buffer2.str + "MΩ" + Tolerances[Tolerance]; // Problem
return z;
}
return "An error occured, please try again...\n";
}
The errors being thrown are:
error C3867: 'std::basic_istringstream<_Elem,_Traits,_Alloc>::str': function call missing argument list; use '&std::basic_istringstream<_Elem,_Traits,_Alloc>::str' to create a pointer to member
error C2679: binary '+=' : no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion)
Thanks,
Jamie