POD类成员订单 [英] POD class member order

查看:102
本文介绍了POD类成员订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的POD课程中:


class MyPodClass

{

public:

MyPodClass (MyCtorArgs);

...

私人:

短数据1;

短数据2;

长数据3;

};


我可以依赖数据项的顺序

为他们出现了?章&诗歌?


感谢您的帮助。

迈克。

解决方案

Mike - EMAIL IGNORED写道:

在我的POD课程中:

class MyPodClass
{
公开:
MyPodClass( MyCtorArgs);
...
私人:
短数据1;
短数据2;
长数据3;
};
我可以依赖数据项的顺序吗?章&是吗?




您只能在两个不同的访问说明符之间。 9.2 / 12.


V

-

请在邮寄回复时从我的地址中删除资金


Mike - EMAIL IGNORED写道:

在我的POD课程中:

class MyPodClass
{<公开:
MyPodClass(MyCtorArgs);
...
私人:
短数据1;
短数据2;
长数据3;
};

我可以依赖数据项的顺序吗?




取决于是否你想知道POD课程的答案或你的

例子(绝对不是POD),答案是肯定的或不是。


Rolf Magnus写道:

Mike - EMAIL IGNORED写道:

在我的POD课程中:

课堂MyPodClass
{
公开:
MyPodClass(我的CtorArgs);
...
私人:
短数据1;
短数据2;
长数据3;
};
我可以依赖数据项的顺序吗?



取决于您是想知道POD类的答案还是
你的
例子(绝对不是POD),答案是肯定还是否定。




看起来对我来说是PODdy - 为什么它不是POD?


Mike:是的,它是POD,而C ++定义了

访问说明符之间的数据成员的顺序(private:" )。您的实现必须在数据成员之间和之后定义包装



请编写有效的简单代码,不要memcpy()这些数据,或者

eqivalent。

-

Phlip
http://www.greencheese.org/ZeekLand < - 不是博客!!!


In my POD class:

class MyPodClass
{
public:
MyPodClass(MyCtorArgs);
...
private:
short data1;
short data2;
long data3;
};

Can I rely on the order of the data items
being as they appear? Chapter & verse?

Thanks for your help.
Mike.

解决方案

Mike - EMAIL IGNORED wrote:

In my POD class:

class MyPodClass
{
public:
MyPodClass(MyCtorArgs);
...
private:
short data1;
short data2;
long data3;
};

Can I rely on the order of the data items
being as they appear? Chapter & verse?



You can, only between two different access specifiers. 9.2/12.

V
--
Please remove capital As from my address when replying by mail


Mike - EMAIL IGNORED wrote:

In my POD class:

class MyPodClass
{
public:
MyPodClass(MyCtorArgs);
...
private:
short data1;
short data2;
long data3;
};

Can I rely on the order of the data items
being as they appear?



Depending on whether you want to know the answer for a POD class or for your
example (which is definitely not a POD), the answer is either yes or no.


Rolf Magnus wrote:

Mike - EMAIL IGNORED wrote:

In my POD class:

class MyPodClass
{
public:
MyPodClass(MyCtorArgs);
...
private:
short data1;
short data2;
long data3;
};

Can I rely on the order of the data items
being as they appear?



Depending on whether you want to know the answer for a POD class or for
your
example (which is definitely not a POD), the answer is either yes or no.



It look PODdy to me - why it not a POD?

Mike: Yes, it''s a POD, and C++ defines the order of data members between
access specifiers ("private:"). Your implementation must define the packing
between and after data members.

Please write simple code that works, and do not memcpy() this data, or the
eqivalent.
--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!


这篇关于POD类成员订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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