memset'this'在构造函数中? [英] memset 'this' in constructor?

查看:75
本文介绍了memset'this'在构造函数中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好!


我正在上课,只有300多个指针,我需要设置

它们全部为NULL,当对象时创造了。


我认为最好的方式是


memset(这,NULL,sizeof(classname));


你的建议是什么?

这会破坏什么吗?因为它是在构造函数中完成的?


任何建议???

hi Guys!

I am having a class, having around 300+ pointers ONLY, I need to set
them all NULL, when the object is created.

The best way I think is

memset(this, NULL, sizeof(classname));

whats your suggestion??
Will this break anything?? as it is done in constructor??

any suggestions???

推荐答案

伙计们你们都有什么建议删除?因为这个班级只有指针作为成员变量,所以

hack_tick写道:
Also guys what do you all suggest about deleting?? as this class is
only going to have Pointers as member variable,
hack_tick wrote:
嗨伙计们!
我正在上课,只有300多个指针,我需要在创建对象时将它们全部设置为NULL。

我认为最好的方法是

memset(这个,NULL,sizeof(classname));

你的建议是什么?
这会破坏什么吗?因为它是在构造函数中完成的?

任何建议???
hi Guys!

I am having a class, having around 300+ pointers ONLY, I need to set
them all NULL, when the object is created.

The best way I think is

memset(this, NULL, sizeof(classname));

whats your suggestion??
Will this break anything?? as it is done in constructor??

any suggestions???






hack_tick写道:
hack_tick wrote:
嗨伙计们!

我正在上课,只有300多个指针,我需要在创建对象时将它们全部设置为NULL。

我认为最好的方法是memset(这个,NULL,sizeof(classname));
这会将你对象的虚拟fn指针变为NULL。

你的建议是什么?
这会破坏什么吗?因为它是在构造函数中完成的?

任何建议???
hi Guys!

I am having a class, having around 300+ pointers ONLY, I need to set
them all NULL, when the object is created.

The best way I think is

memset(this, NULL, sizeof(classname)); This will turn the virtual fn pointer of your object to NULL.

whats your suggestion??
Will this break anything?? as it is done in constructor??

any suggestions???








hack_tick写道:

hack_tick wrote:
嗨伙计们!

我正在上课,只有300多个指针,我需要将它们全部设为NULL,当对象已创建。

我认为最好的方法是memset(这,NULL,sizeof(classname));

你的建议是什么??这会打破什么吗?因为它是在构造函数中完成的?

任何建议???
hi Guys!

I am having a class, having around 300+ pointers ONLY, I need to set
them all NULL, when the object is created.

The best way I think is

memset(this, NULL, sizeof(classname));

whats your suggestion??
Will this break anything?? as it is done in constructor??

any suggestions???




至少有两件事需要关注。

1.您是否从任何类派生过此类?

如果是,但您可能会说Base中没有任何数据成员

类(请阅读2)

2.本课程中是否有任何虚拟方法?



You have at least two things to be concern.
1. Have you derived this class from anyclass?
If yes, but you might say that there isn''t any data member in Base
class (please read 2)
2. Is there any virtual method inside this class?


这篇关于memset'this'在构造函数中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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