由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - c++中的inline 函数是做什么的?
相关主题
inline到底能省多少时间?在看the effective C++language
A tech question (转载)C编译器为何允许一个函数在某个路径不返回值?
interview question: make all class member functions virtual (转载)inline functions in C++
c++标准函数传递一问inline C function in VC++ 2005 express
static variable in template header码工试题 (转载)
inline function是否可以递归?请教C++里面这个表达
[合集] another question for C++ constant请教:函数后面的 throw() 有意义么?
looking for a compact C/VC++ compiler; any recommendations?关于C++中const的问题
相关话题的讨论汇总
话题: inline话题: c++话题: 函数话题: linkage话题: static
进入Programming版参与讨论
1 (共1页)
h*****g
发帖数: 944
1
谢谢
d****i
发帖数: 4809
2
就好像你可以在class的定义中直接定义method而不放在C++文件中:
class Foo {
public:
void myFunc() {
//blah blah....
}
};
但是complier可以忽略inline keyword。

【在 h*****g 的大作中提到】
: 谢谢
T*****u
发帖数: 7103
3
如果这个函数需要叫很多遍,inline就不用叫了,节省运行时间, at the代价of读和
维护的时间。
c*******y
发帖数: 1630
4
那两个回复都不准确,去google c++ faq
里面有一个section关于inline的,详尽一些。

【在 h*****g 的大作中提到】
: 谢谢
r*****e
发帖数: 792
5
如果没记错的话,那里的解释就是用了inline有可能快也有可能慢,
binary size会变大也可能会变小。

【在 c*******y 的大作中提到】
: 那两个回复都不准确,去google c++ faq
: 里面有一个section关于inline的,详尽一些。

g*********e
发帖数: 14401
6
就跟C里面的MACRO一样
i***c
发帖数: 26
7
著名的贴代码。

【在 h*****g 的大作中提到】
: 谢谢
n*******h
发帖数: 67
8
就是假function. 其实compiler帮你copy & paste code.

【在 h*****g 的大作中提到】
: 谢谢
H**r
发帖数: 10015
9

类似deep copy过来吧?

【在 n*******h 的大作中提到】
: 就是假function. 其实compiler帮你copy & paste code.
b*******s
发帖数: 5216
10
deep copy是不同的概念
这个就是提示编译器:coder认为这个函数适宜在使用处展开以减小调用开销

【在 H**r 的大作中提到】
: 恩
: 类似deep copy过来吧?

m***x
发帖数: 492
11
现有的compiler 大多忽略inline,它自己决定了怎么办

【在 b*******s 的大作中提到】
: deep copy是不同的概念
: 这个就是提示编译器:coder认为这个函数适宜在使用处展开以减小调用开销

S*******s
发帖数: 13043
12
去掉inline的后果就是一大堆链接错误

【在 m***x 的大作中提到】
: 现有的compiler 大多忽略inline,它自己决定了怎么办
t****t
发帖数: 6806
13
make it static will fix. inline means internal linkage, without inline it's
external linkage by default. static makes it internal again.

【在 S*******s 的大作中提到】
: 去掉inline的后果就是一大堆链接错误
1 (共1页)
进入Programming版参与讨论
相关主题
关于C++中const的问题static variable in template header
Intel C++ compiler 求教inline function是否可以递归?
问一个windows下编译openGL code的问题[合集] another question for C++ constant
老年工程师转行学C++的更新的问题looking for a compact C/VC++ compiler; any recommendations?
inline到底能省多少时间?在看the effective C++language
A tech question (转载)C编译器为何允许一个函数在某个路径不返回值?
interview question: make all class member functions virtual (转载)inline functions in C++
c++标准函数传递一问inline C function in VC++ 2005 express
相关话题的讨论汇总
话题: inline话题: c++话题: 函数话题: linkage话题: static