#include <iostream>
#include <string>
using namespace std;
class Base{
public:
Base(string x){m_x=x;}
// Base(float x){m_x=x;}
operator string() const{return m_x;}
// operator float() const{return m_x;}
private:
string m_x;
// float m_x;
};
int main(void){
Base b("102.5");
// Base b(102.5);
cout<<b<<endl;
return 0;
}
为什么float型不报错而转成string会报错呢?