ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
~~~ #include <iostream> #include <string> using namespace std; class Maker { friend ostream& operator<<(ostream &out, Maker &m); public: Maker(int id, string name) { this->id = id; this->name = name; } public: int id; string name; }; ostream& operator<<(ostream &out, Maker &m) { cout << m.id << " " << m.name << endl; return out; } void test01() { Maker m(10, "小花"); cout << m << endl; cout << endl; } int main() { test01(); getchar(); return EXIT_SUCCESS; } ~~~