内嵌代码 [英] inline-code

查看:51
本文介绍了内嵌代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




i对内联代码有一个简单的问题:


class x {

private:

int xx;

public:

int getXX(void){return x; }

};


与之相同:


class x {
$ b $私人:

int xx;

public:

int getXX(void);

};


inline int x :: getXX(void)

{

返回x;

}


或者这些代码之间有什么区别?


谢谢

Stephan



i have a simple question for inline code :

class x {
private:
int xx;
public:
int getXX(void){ return x; }
};

is the same like :

class x {
private:
int xx;
public:
int getXX( void );
};

inline int x::getXX( void )
{
return x;
}

or is a differenz between these code ?

thanks
Stephan

推荐答案

2004年1月19日星期一16:23:48 +0100,Stephan Winter写道:
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:
hi,
我对内联代码有一个简单的问题:

int getXX(void){return x; }
inline int x :: getXX(void)
或者是这些代码之间的差异?


i have a simple question for inline code :
int getXX(void){ return x; } inline int x::getXX( void ) or is a differenz between these code ?




有_may_是有区别的。第一种内联是在你编译代码#include -ing头文件的时候完成的。第二个是在链接阶段请求内联
。它可能会或可能不会。


阅读您的编译器和链接器文档。


-

NPV


大字打印,小字打印

Tom Waits - 向上走吧



There _may_ be a difference. The first kind of inlining is done when you
compile the code #include-ing the header file. The second is a request to
do inlining at the linking stage. Which it may or may not do.

Read your compiler and linkers documentation.

--
NPV

"the large print giveth, and the small print taketh away"
Tom Waits - Step right up


2004年1月19日星期一16:23:48 +0100,Stephan Winter写道:
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:


我对于内联代码有一个简单的问题:


[snip inclass-definition和outclass-inline-definition]

或这些代码之间的区别是什么?


i have a simple question for inline code :
[ snip inclass-definition and outclass-inline-definition ]
or is a differenz between these code ?




不,它们是等价的。


HTH,

M4




" Martijn Lievaart" < m@remove.this.part.rtij.nl>在消息中写道

news:pa **************************** @ remove.this.pa rt。 rtij.nl ...

"Martijn Lievaart" <m@remove.this.part.rtij.nl> wrote in message
news:pa****************************@remove.this.pa rt.rtij.nl...
2004年1月19日星期一16:23:48 +0100,Stephan Winter写道:
On Mon, 19 Jan 2004 16:23:48 +0100, Stephan Winter wrote:


我对内联代码有一个简单的问题:
[snip inclass-definition和outclass-inline-definition]


i have a simple question for inline code :
[ snip inclass-definition and outclass-inline-definition ]
或者这些代码之间是否存在差异?
or is a differenz between these code ?



不,它们是等价的。



No, they are equivalent.




我不认为这是正确的。据我了解,内联关键字是

实际上只是内联代码的建议/请求。

编译器/链接器可能*不*内联它。这不对吗?


HTH,
M4



I don''t think that''s correct. As I understand it, the inline keyword is
actually just a suggestion/request to inline the code. It''s possible that
the compiler/linker may *not* inline it. Isn''t that correct?

HTH,
M4



这篇关于内嵌代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆