使用方法就是在对应类里面编写operator对应成员函数:
例如:1
2
3operator string() {}
operator int () {}
operator double() {}
可以利用重载类型转换运算符,编写一个类来实现可以存储double类型和string类型的输入,并且输出时候仍然输出对应的double或者string
1 |
|
使用方法就是在对应类里面编写operator对应成员函数:
例如:1
2
3operator string() {}
operator int () {}
operator double() {}
可以利用重载类型转换运算符,编写一个类来实现可以存储double类型和string类型的输入,并且输出时候仍然输出对应的double或者string
1 | #include <iostream> |
WeChat Pay
Alipay