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

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

 

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

 

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

你可能感兴趣的:(C++,String,delete,System,笑话,电话)