case 1: using const and inline instead of #define
reason :when complier complain a error for "1.653", we may not realize it is a Macro.
1.how to define a const pointer?
const char* const authorName = "Deman Lu";
2.define a static const member in class.
we should define it bouth in class body and in cpp file .
3. may be you can use enum for a const member.
case 1.2 using inline function to define function.
template<class T>
inline const T& max(const T& a, const T& b)
{return a>b ? a:b;}
case 2: using <iostream> instead of <stdio.h> and <iostream.h>
operator>> and operator << can using int, double, sring by default.
case 3:using new and delete instead of malloc and free.
new and delete will call constructors and destructors.
case 4: using C++ annotation instead of C style
using // not /**/
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文链接: https://www.cnblogs.com/deman/archive/2013/01/03/4716584.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/74377
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!