标签:
今天是春节呢。写一个小程序玩。
#include <iostream> #include <string> using namespace std; class guy { public: guy(string nam):name(nam){} void love(guy&); //类的引用作为参数 private: string name; }; void guy::love(guy& p) { cout<<name<<" loves "<<p.name<<‘!‘<<endl; } int main() { guy I("Walter"),You("Bright"); I.love(You); //“核心”代码 return 0; }
标签:
原文地址:http://www.cnblogs.com/shuiming/p/5185340.html