使用“this”在基本初始化列表中? [英] Using "this" in a base initializer list?

查看:67
本文介绍了使用“this”在基本初始化列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!以下代码是否格式错误或是否产生未定义的

行为:


class a


{};


class b

{


public:


b(a&){}

};


class c:private a,private b


{


public:


c():b(* this){}


};

Hello! Is the following code illformed or does it yield undefined
behaviour:

class a

{};

class b

{

public:

b(a&){}

};

class c: private a, private b

{

public:

c():b(*this){}

};

推荐答案

Angel Tsankov写道:
Angel Tsankov wrote:

你好!以下代码是否格式错误或是否产生未定义的

行为:


class a


{};


class b

{


public:


b(a&){}

};


class c:private a,private b


{


public:


c():b(* this){}


};
Hello! Is the following code illformed or does it yield undefined
behaviour:

class a

{};

class b

{

public:

b(a&){}

};

class c: private a, private b

{

public:

c():b(*this){}

};



两者都没有。代码很好。


V

-

请在回复电子邮件时删除资金'A'邮件

我没有回复最热门的回复,请不要问

Neither. The code is fine.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


5月8日上午9:21, ;天使Tsankov < fn42 ... @ fmi.uni-sofia.bgwrote:
On May 8, 9:21 am, "Angel Tsankov" <fn42...@fmi.uni-sofia.bgwrote:

您好!以下代码是否格式错误或是否产生未定义的

行为:


class a


{};


class b

{


public:


b(a&){}

};


class c:private a,private b


{


public:


c():b(* this){}
Hello! Is the following code illformed or does it yield undefined
behaviour:

class a

{};

class b

{

public:

b(a&){}

};

class c: private a, private b

{

public:

c():b(*this){}



不明确的电话。 b(const b&)和b(a&)

Ambiguous call. b(const b&) and b(a&)


>


}; - 隐藏引用的文字 -


- 显示引用文字 -
>

};- Hide quoted text -

- Show quoted text -



siddhu写道:
siddhu wrote:

5月8日上午9:21,Angel Tsankov < fn42 ... @ fmi.uni-sofia.bgwrote:
On May 8, 9:21 am, "Angel Tsankov" <fn42...@fmi.uni-sofia.bgwrote:

>你好!以下代码是否格式错误或是否产生未定义的行为:

类a

{};

类b
公共:

b(a&){}

};

类c:私人a,私人b

公开:

c():b(* this){}
>Hello! Is the following code illformed or does it yield undefined
behaviour:

class a

{};

class b

{

public:

b(a&){}

};

class c: private a, private b

{

public:

c():b(*this){}



不明确的电话。 b(const b&)和b(a&)


Ambiguous call. b(const b&) and b(a&)



你是对的!我怎么想念那个? < redface>

You''re right! How did I miss that? <redface>


>

>


>>

}; - 隐藏引用的文字 -

- 显示引用的文字 -
>>

};- Hide quoted text -

- Show quoted text -



V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要''请问

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


这篇关于使用“this”在基本初始化列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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