Home > Back-end >  Why always shows stringToNum is undefined identifiers?
Why always shows stringToNum is undefined identifiers?

Time:09-29

I saw in the recently to do programming assignments have bosses did not define stringToNum called directly without error, but in my here has been an error "undefined identifiers," added the Internet the way defined but no effect, want to ask how to solve this kind of circumstance?
The template & lt; The class Type & gt;
Type CurveDataModel: : stringToNum (const STD: : string& STR)
{
STD: : istringstream iss (STR);
Type num.
Iss & gt;> Num.
return num;
}
X=stringToNum (x_string);
Y=stringToNum (y_string);
Z=stringToNum (z_string);
NumberPrecision=Max (numberPrecision, Max (getNumberPrecision (x_string),
Max (getNumberPrecision (y_string), getNumberPrecision (z_string))));

This is a small part of the code, there are several mistakes, to collapse!

CodePudding user response:

What is
X=stringToNum (x_string),
Y=stringToNum (y_string),
Z=stringToNum (z_string);
Change so that is not an error! It is the metaphysics...

CodePudding user response:

Not a metaphysics, template function was so,
Because the template function is not a function, but a template, only depending on the template parameters can identify a specific function
For example,
Template
T Max (T, a, T, b);
So max (.. ) and max (... ) is actually two function

If you specify a, b type, which can be deduced T
You can directly to the Max (a, b), if it cannot be derived must specify the template parameter type
So call
Max (a, b);
  • Related