offsetof / non-POD结构 [英] offsetof / non-POD structs

查看:126
本文介绍了offsetof / non-POD结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想在非POD结构上使用offsetof,但当然这是

undefined。我怎么能得到同样的效果呢?


谢谢,

戴夫

Hello all,

I would like to use offsetof on a non-POD struct, but of course this is
undefined. How else may I get the same effect?

Thanks,
Dave

推荐答案

Dave写道:
我想在非POD结构上使用offsetof,但当然这是未定义的。我怎么能得到同样的效果呢?
I would like to use offsetof on a non-POD struct, but of course this is
undefined. How else may I get the same effect?




你不能。



You cannot.


2005年12月13日星期二15 :51:12-0700,戴夫 < be *********** @ yahoo.com>

写道:
On Tue, 13 Dec 2005 15:51:12 -0700, "Dave" <be***********@yahoo.com>
wrote:
大家好,

谢谢,
戴夫
Hello all,

I would like to use offsetof on a non-POD struct, but of course this is
undefined. How else may I get the same effect?

Thanks,
Dave




什么是相同的效果? ......为什么你需要这样做?也许

有一种C ++方式可以做你需要做的事......


如果你理解为什么它是未定义的,你就会明白为什么呢

a做坏事(就像那样)。


-

Bob Hairgrove No**********@Home.com


2005年12月13日星期二15:51:12 -0700 comp.lang.c ++,Dave

< be ****** *****@yahoo.com>写道,
On Tue, 13 Dec 2005 15:51:12 -0700 in comp.lang.c++, "Dave"
<be***********@yahoo.com> wrote,
我想在非POD结构上使用offsetof,但当然这是未定义的。我怎么能得到同样的效果?
I would like to use offsetof on a non-POD struct, but of course this is
undefined. How else may I get the same effect?




使用指向成员的指针(非常深奥。)

参见Stroustrup第15.5节



Use pointer-to-member (pretty esoteric.)
See Stroustrup section 15.5


这篇关于offsetof / non-POD结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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