多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 实例类型转换 <details> <summary>main.cpp</summary> ``` #include <iostream> #include <string> using namespace std; class ABC { public: int age; string name; ABC(int a,string n):age(a),name(n) { } operator int() // ABC -> int { return age; } operator string() // ABC -> string { return name; } }; int main() { ABC abc(12,"idcpj"); cout << abc+12 <<endl; // 24 string abcstr=abc; cout << abcstr <<endl; // idcpj return 0; } ``` </details> <br/>