Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:22:13+00:00 2026-06-15T10:22:13+00:00

i’m struggling and trying to understand why the following code is not working. I

  • 0

i’m struggling and trying to understand why the following code is not working.

I have 3 classes defined as:

class VertexType
{
public:
    VertexType(void) { };
    virtual ~VertexType() = 0;
};

class PositionColorVertex
    : public VertexType
{
public:
    PositionColorVertex(XMFLOAT3 _position, XMFLOAT4 _color)
    :Position(_position), Color(_color)
    {};
    ~PositionColorVertex() {};

    static const UINT size = 28;

    XMFLOAT3 Position;
    XMFLOAT4 Color;
};

class PositionVertex
    : public VertexType
{
public:
    PositionVertex(XMFLOAT3 _position)
    :Position(_position)
    {};
    ~PositionVertex() {};

    static const UINT size = 12;

    XMFLOAT3 Position;
};

The array initialization is working for:

PositionVertex vertices[] = { XMFLOAT3(0,0,0) };

but when i try to initialize with:

PositionColorVertex vertices[] = {
{ XMFLOAT3(0,0,0), XMFLOAT4(0,0,0,1) } };

i get an error C2552 non-aggregates cannot be initialized with initializer list.

Why PositionVertex is working whereas PositionColorVertex isn’t ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:22:13+00:00Added an answer on June 15, 2026 at 10:22 am

    Why PositionVertex is working whereas PositionColorVertex isn’t ?

    Because in the first case you are initializing an array, which is an aggregate:

    PositionVertex vertices[] = { XMFLOAT3(0,0,0) };
    

    In the second case, you are attempting to initialize a PositionVertexColor with an initializer list containing two elements, then use that to initialize a size-1 array. The first part only works in C++11. You can visualize it better by splitting this:

    PositionVertexColor vertices[] = { {XMFLOAT3(0,0,0), XMFLOAT4(0,0,0,1)} };
    

    into two:

    PositionVertexColor pvc =  {XMFLOAT3(0,0,0), XMFLOAT4(0,0,0,1)}; // Error, non-aggregate.
    PositionVertexColor vertices[] = { pvc }; // would be OK if first step had worked
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.