码迷,mamicode.com
首页 > 其他好文 > 详细

I.love(You)

时间:2016-02-09 01:20:16      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

今天是春节呢。写一个小程序玩。

#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;
}

 

I.love(You)

标签:

原文地址:http://www.cnblogs.com/shuiming/p/5185340.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!