Converting string to numeric

In my program I need to convert a String variable to numeric float variable.

For example:
String Weight="1234.56";
float WVal=atof(Weight);

I'm getting error: cannot convert 'String' to 'const char*' for argument '1' to 'double atof(const char*)'

Why is that error? is there a different way to convert a sting to numeric?
I would appreciate any help

Thanks

The simplified answer:
a) the String library is a class (object). A class can contain member variables, constants, member functions, and overloaded operators. Its a c++ thing
b) atof expect an argument of type const char * str
c) to convert the string class to a const char * str

char buf[Weight.length()];
Weight.toCharArray(buf,Weight.length());
float WVal=atof(buf);

Just as a side note, I dislike converting to different types. It can inject errors and drive you crazy debugging. I find it better in the long run to redesign the code to use the type I need, if possible.