在课堂上使用内联? [英] Use Inline in class?

查看:78
本文介绍了在课堂上使用内联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这种做法是否最好。我是否需要在类定义或外部成员函数中放置内联

关键字

定义。例如


class A

{

public:

A();

~A();


inline void Test(); //应该在这里放置内联?

};


inline void A :: Test()//应该在这里放置内联?

{

{

I want to know if the practice is the best. Do I need to place inline
keyword inside class definition or outside member function
definition. For example

class A
{
public:
A();
~A();

inline void Test(); // should place inline here?
};

inline void A::Test() // should place inline here?
{
{

推荐答案

On 7 ??6è?,é???8ê±31·?,不朽的尼腓< Immortal_Ne .... @ satx.rr.comwrote:
On 7??6è?, é???8ê±31·?, Immortal Nephi <Immortal_Ne....@satx.rr.comwrote:

我想知道这种做法是否最好。我是否需要在类定义或外部成员函数中放置内联

关键字

定义。例如


class A

{

public:

A();

~A();


inline void Test(); //应该在这里放置内联?
I want to know if the practice is the best. Do I need to place inline
keyword inside class definition or outside member function
definition. For example

class A
{
public:
A();
~A();

inline void Test(); // should place inline here?



不需要

no need


};


inline void A :: Test()//应该在这里放置内联?

{

{
};

inline void A::Test() // should place inline here?
{
{



是的,你需要。


另一种方法是在课堂上定义func。

A级{

public:

void Test(){...};

};

测试被称为内联。

yes, you need.

another way is to define func in class.
class A{
public:
void Test(){...};
};
Test is refered as inline.


不朽的Nephi写道:
Immortal Nephi writes:

我想知道这种做法是否最好。我是否需要在类定义或外部成员函数中放置内联

关键字

定义。例如


class A

{

public:

A();

~A();


inline void Test(); //应该在这里放置内联?
I want to know if the practice is the best. Do I need to place inline
keyword inside class definition or outside member function
definition. For example

class A
{
public:
A();
~A();

inline void Test(); // should place inline here?



No.

No.


};


inline void A :: Test()//应该在这里放置内联?
};

inline void A::Test() // should place inline here?



是的。


----- BEGIN PGP SIGNATURE -----

版本:GnuPG v1.4.9(GNU / Linux)

iEYEABECAAYFAkhwGSoACgkQx9p3GYHlUOI + NQCbBuUnXa7tCU MjpcGCPo9YKvbA

yFwAn271esMxKOBacxrSFw31D46g17m3

= TrHL
-----结束PGP签名-----

Yes.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkhwGSoACgkQx9p3GYHlUOI+NQCbBuUnXa7tCU MjpcGCPo9YKvbA
yFwAn271esMxKOBacxrSFw31D46g17m3
=TrHL
-----END PGP SIGNATURE-----


Immortal Nephi写道:
Immortal Nephi wrote:

我想知道这种做法是否最好。我是否需要在类定义或外部成员函数中放置内联

关键字

定义。例如


class A

{

public:

A();

~A();


inline void Test(); //应该在这里放置内联?

};


inline void A :: Test()//应该在这里放置内联?

{

{
I want to know if the practice is the best. Do I need to place inline
keyword inside class definition or outside member function
definition. For example

class A
{
public:
A();
~A();

inline void Test(); // should place inline here?
};

inline void A::Test() // should place inline here?
{
{



如果你想在类外定义你的内联成员函数

定义(如上例所示),您只需在成员定义中指定''inline''

(在您的示例中为第二个''inline'')


A级{

...

无效测试();

...

} ;


inline void A :: Test()

{

}


-

祝你好运,

Andrey Tarasevich

If you want to define your inline member function outside the class
definition (as in your example above), you only need to specify ''inline''
in the member definition (the second ''inline'' in your example)

class A {
...
void Test();
...
};

inline void A::Test()
{
}

--
Best regards,
Andrey Tarasevich


这篇关于在课堂上使用内联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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