c++中的高度级别
#include?<iostream>
#include?<string>
using?namespace?std;
#define?DEBUG?2
#if?DEBUG<2
#define?ASSERT(x)
#else
#define?ASSERT(x)\if?(!(x))\
{\cout<<"錯誤!ASSERT("<<#x<<")宏函數執行檢測\n";\cout<<"錯誤代碼出現在第"<<__LINE__<<"行\n";\cout<<"出錯的文件在:"<<__FILE__<<"\n";\
}
#endif
#if?DEBUG<3#define?SHOW(x)
#else#define?SHOW(x)\cout<<x<<endl;
#endif
#if?DEBUG<4#define?PRINT(x)
#else#define?PRINT(x)\cout<<#x<<endl;
#endif
class?Circle
{
public:double?check()const{SHOW("進行3級檢查");PRINT("進行4級檢查");return?radius;}void?set(double?x){ASSERT(check());radius=x;ASSERT(check());}double?Result(){return?3.14*radius*radius;}
private:double?radius;
};
int?main()
{Circle?one;one.set(14);cout<<"圓的面積為:"<<one.Result()<<endl;one.set(0);cout<<"圓的面積為:"<<one.Result()<<endl;getchar();return?0;
}
總結
- 上一篇: delphi中覆盖最大化消息
- 下一篇: 简单在于的acdsee 2012