那些年笑不死你的程序猿(一)=====原创

【笑不死你的程序猿1

序媛小芳最近发现他老公最近有点不对劲,老是很晚回家,心里很纳闷,于是拿出传说中的面相对象编程的大法,针对对象好好编程一番

Class MyHusband

{

Public:

     MyHusband();

~MyHusband();

 

Public:

    //恨死了有木有????

Bool SpendMoneyForOtherGirls(double LotsOfMoney)

{

   Return LotsOfMomeyForLV();

}

Private:

   Double myMoney;

};

 

翻开《葵花宝典》同著《C++变成死相》(PS:同名于《C++编程思想》纯属巧合),于是她想到了有以下这些可以解决问题的方法:

1.”阉割他”, 把MyHusband()构造函数 由public变为private, 失去被继承能力了吧?看你妹的还能和别人厮混

 

Class MyHusband

{

Private:

     MyHusband();

Public:

~MyHusband();

 

Public:

Bool SpendMoneyForOtherGirls(double LotsOfMoney)

{

   Return LotsOfMomeyForLV();

}

Private:

   Double myMoney;

};

 

2.采取单例模式给个“今生只爱我”药给他吃,只能接触GetInstance()函数

 

Class MyHusband

{

Private:

     MyHusband();

Public:

~MyHusband();

 

Public:

Bool SpendMoneyForOtherGirls(double LotsOfMoney)

{

   Return LotsOfMomeyForLV();

}

Public:

MyHusband* GetInstance();

{

If(pUBelongToMe!=NULL)return pUBelongToMe;

Else pUBelongToMe= MyHusband();

Return pUBelongToMe

}

Private:

   Double myMoney;

   MyHusband*pUBelongToMe;

};

 

3.SpendMoneyForOtherGirls改成纯虚函数,够狠了吧,没收监视所有小金库,看你妹的还花的到老娘的钱泡妹纸不?

Class MyHusband

{

Public:

     MyHusband();

~MyHusband();

 

Public:

Virtual Bool SpendMoneyForOtherGirls(double LotsOfMoney)=0;

Private:

    Static Double myMoney;

};

4.给你加把锁,钥匙在我手里,让你只属于我一个人

Class MyHusband

{

Private

     MyHusband();

Public:

~MyHusband();

 

Public:

Bool SpendMoneyForOtherGirls(double LotsOfMoney)

{

   Return LotsOfMomeyForLV();

}

Public:

MyHusband* GetHusband();

{

If(!mbLock)

{

mbLock=true;

retuen new MyHusband;

}

Else return NULL;

}

Private:

   Double myMoney;

   Static bool mbLock;

};

 

记住每个类后面加“;”哟,不然真是在裸奔了~~~~~

=================Author By OneDream工作室===================

此笑话纯属原创笑话~~看懂的就笑一下,看不懂那就赶快去学吧

~~~~每天你开心我就开心O(_)O~~

posted on 2014-08-19 10:02  AAAAAApple  阅读(172)  评论(0编辑  收藏  举报

导航