您的位置:首页 > 编程语言 > C语言/C++

[C++] 有关程序员的笑话

2011-02-14 13:09 302 查看
老婆给当程序员的老公打电话:“下班顺路买一斤包子带回来,如果看到卖西瓜的,就买一个。”当晚,程序员老公手捧一个包子进了家门……老婆怒道:“你怎么就买了一个包子?!”老公答曰:“因为看到了卖西瓜的。”



我承认我很闲....=.=



#include<iostream>
#include<string>
using namespace std;

class Bun
{
private:
    int m_num;
    string m_unit;
public:
    Bun(){}
    Bun(int num,string unit)
    {
        ChangeBun(num,unit);
    }
    void PrintBun()
    {
        cout<<"buy bun "<<m_num<<" ";
        cout<<m_unit<<endl;
    }
    void ChangeBun(int num,string unit)
    {
        m_num = num;
        m_unit = unit;
    }
};

bool IsFoundWatermelonStall()
{
    cout<<"看到賣西瓜的了"<<endl;
    return true;
}

int main()
{
    cout<<"去買一斤包子,看到賣西瓜的,就買一個"<<endl;
    Bun* bun = new Bun(1,"斤");
    bun->PrintBun();
    if(IsFoundWatermelonStall())
        bun->ChangeBun(1,"個");
    bun->PrintBun();
    delete bun;
    system("pause");
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: