开发者

How to init structs when creating with new

is it possible to somehow to this when creating 开发者_开发问答structs with new

SMSD3DVertex[] =    {   {1.0f,-1.0f,10.0f,0xff0fff00},
                                            {3.0f,-1.0f,10.0f,0xffffff00},
                                            {1.0f,1.0f,10.0f,0xffffff00},
                                            {3.0f,1.0f,10.0f,0xffff0f00}
                                    };

the first one is correct, how can i write it correctly with the on heap creation with new as posted below. thx for answer.

m_pVertex = new SMSD3DVertex[4] {   {1.0f,-1.0f,10.0f,0xff0fff00},
                                            {3.0f,-1.0f,10.0f,0xffffff00},
                                            {1.0f,1.0f,10.0f,0xffffff00},
                                            {3.0f,1.0f,10.0f,0xffff0f00}
                                    };


 class Initializer : public SMSD3DVertex {
    public:
       Initializer(float f1, ..., unsigned int hex) {
          /* set all the fields */
 };

Initializer 'is-a' SMSD3DVertex, so you new one of these and store the pointer as a SMSD3DVertex *.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜