c++ - inline放在哪好
来源:互联网 发布:js通过数据库表单验证 编辑:程序博客网 时间:2024/06/10 00:09
Best practice: only in the definition outside the class body.
public:
void method(); ← best practice: don't put the inline keyword here
...
};
inline void Foo::method() ← best practice: put the inline keyword here
{ ... }
Here's the basic idea:
- The
public: part of the class body is where you describe the observable semantics of a class, its public member functions, its friend functions, and anything else exported by the class. Try not to provide any inklings of anything that can't be observed from the caller's code. - The other parts of the class, including non-
public: part of the class body, the definitions of your member and friend functions, etc. are pureimplementation. Try not to describe any observable semantics that were not already described in the class'spublic: part.
From a practical standpoint, this separation makes life easier and safer for your users. Say Chuck wants to simply "use" your class. Because you read this FAQ and used the above separation, Chuck can read your class's
Back to inline-ness: the decision of whether a function is or is not inline is animplementation detail that does not change the observable semantics (the "meaning") of a call. Therefore the inline keyword should go next to the function's definition, not within the class's
http://www.parashift.com/c++-faq-lite/inline-functions.html
- c++ - inline放在哪好
- inline:我应该把你放在哪?
- Android Studio编译好的apk放在哪
- C++:为什么inline函数的定义要放在头文件里 + inline和宏定义的区别(暂未体会到)
- inline函数定义放在头文件中的作用
- inline函数的定义放在头文件中
- 放在浏览器看的好东西
- script放在HTML哪里比较好?
- C语言在VS里使用 inline
- C++中inline函数的定义可放在头文件中,inline 函数重复出现不会导致连接错误,
- Android Studio编译好的apk放在哪里?
- JavaScript脚本放在哪里用户体验好
- 一篇Listview Button始终放在底部的好文章
- Android Studio编译好的apk放在哪里?
- Android Studio编译好的apk放在哪里
- Android Studio编译好的apk放在哪里?
- Android Studio编译好的apk放在哪里?
- 不如整理一下,放在原位,整齐一些就好。
- 如何动态监测系统日志
- ubuntu 卸载旧的内核的方法
- H.264视频编解码的代码移植和优化
- 下载最新版yaffs2的方法
- 明天回家了,透露一下明年的一些计划
- c++ - inline放在哪好
- linux系统死机情况分析与处理方案介绍
- Tomcat+路由+花生壳 步骤:
- H.264算法的DSP移植与优化
- 修改ubuntu的交换分区使用策略
- [Html5]GhoneGap开发音乐播放器
- root用户在ubuntu11.04 没有声音问题
- 如何禁用ubuntu下的触摸板(使用alias)
- Windows 7: 跟踪用户登陆事件