C/C++
「已注销」
这个作者很懒,什么都没留下…
展开
-
C++内联函数
一、引入假设有函数getMax用于取得两数中较大者。const int getMax(const int &a, const int &b){ return a > b ? a : b;}将a > b ? a : b这一操作写成一个函数的好处是:1.清晰:getMax这一名称比a > b ? a : b这条等价语句更清晰地指出了要实现的功能。2.易维护:当需要修原创 2014-01-19 10:22:27 · 959 阅读 · 0 评论 -
switch quantity not an integer
C++中,switch的选择因子只能是整数。比如以下代码就不能通过编译 String s = u->val; switch (s) { case "<": case "=" : return "Op:" + s; case "read" : return "Read"; case "write" :原创 2014-01-01 20:10:23 · 7972 阅读 · 0 评论 -
Keil: error C141: syntax error near 'unsigned'
出错现场:if (!P2) continue;uint t0 = P0; //errort2 = P2;注释处出现错误:error C141: syntax error near 'unsigned'查阅资料,发现错误原因是变量的声明位置不当。在某些C编译器支持的C标准中,C语言声明变量的位置应当在所有可执行语句之前,像上述程序就出现error。一个编译通原创 2013-11-12 11:34:57 · 29258 阅读 · 0 评论