可能重复:
如何在C++中将数字转换为字符串,反之亦然
在csharp
string s1="12345"
string s2="54321"
public double (string s1,string s2)
{
convert.todouble(s1) +convert.to-double(s2)
}
Run Code Online (Sandbox Code Playgroud)
我是如何在c ++中做的,因为没有转换类
除了其他答案,最简单的方法(至少在C++ 11中)将是:
double add(const std::string &s1, const std::string &s2)
{
return std::stod(s1) + std::stod(s2);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
440 次 |
| 最近记录: |