🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ #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; } ~~~