[Solved] A function to set a value to a “label”


You can do that easily by passing label as reference ( I’m expecting label to be a double and not a string ) . Here is how

void setToValue(double &label , double value )
  {
    label = value;
  }

Note that you don’t need to make the function as type double as it is not returning anything useful ( it would just be a waste ).

Or, you could do it like this

void setToValue(string &label,string value)
  {
    label = value;
  }

  int main()
   {
    string label;
    setToValue(label,"25.25");
    cout<<label;    
   }

solved A function to set a value to a “label”