If you need to accumulate a little bit in a day, you just need a little bit.
------------------------------------
While listening to Jay Chou's music, there was a pot of beer next to it. From time to time, I followed the rhythm and gave me two more drinks. So this blog was born. I can't help but feel that this TM is life!
This article introduces CCAssert, which makes the advertising masses love and hate!
--------------------------------------
CCAssert, that is, assertions. Of course, its functions are similar to those of breakpoints.
Using assertions, you can create code with higher stability, better quality, and less error-prone.. The specific usage can be found below:
CCAssert (cond, msg); // The assertion expression cond is true. If it is not true, the string msg information is displayed.
The first example is as follows:
Int I = 10; CCAssert (I <9, "I shoshould small than 10"); // sorry, I am a PE Instructor. // explain the above sentence, I <9 is an asserted expression. When I <9 is true, the program continues to run without interruption. When I> 9, // that is, the I = 10 written above, and the expression is false, the program will be interrupted and then throw this sentence: I shoshould small than 10.
Run the following program, for example:
Yes, you are not mistaken. This is the window. How many days and nights, how many ups and downs, We are staring at it, crying at it, giggle at it...
The second example below is similar to the first one.
Auto boy = Sprite: create ("boy.png"); boy-> setTag (1); // set the tag to 1this-> addChild (boy); auto girl = Sprite :: create ("girl.png"); girl-> setTag (2); // set the tag to 2this-> addChild (girl );Create a function based on the selected genie
Void switchSp (int sp_tag) {switch (sp_tag) {case 1: CCLOG ("choose human is boy"); // select boybreak; case 2: CCLOG ("choose human is girl"); // select girlbreak; default: CCAssert (false, "choose tag shocould be 1 or 2 "); // use assertion break when neither of them is correct ;}}
In a simple explanation, if the input parameter is 1, a boy is selected. If the input parameter is 2, a girl is selected. If not, an error is returned. If the asserted expression is replaced by false or 0, the program can be directly interrupted.
Well, that's it. Please do not consider this short article. In the words of Xiaozhi of The League of legends:Although short, it can be rotated. You know.
Respect Original, reprinted please indicate Source: http://blog.csdn.net/start530/article/details/23000365