Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Structure

Posted on 2002-05-29
3
Medium Priority
?
187 Views
Last Modified: 2010-04-02
I have structure:
 struct CUSTOMVERTEX { FLOAT x, y, z, rhw; DWORD color; };
 const int myarraysize=3;
 CUSTOMVERTEX new_Vertices[myarraysize];

I trying this:
 new_Vertices[0].x = 60.0f;
 new_Vertices[0].y = 60.0f;
 new_Vertices[0].z = 0.5f;
 new_Vertices[0].rhw = 1.0f;
 new_Vertices[0].color = 0xffff0000;
Works fine, but I don't want it like this...

I trying this:
 new_Vertices[0] =  {60.0f,  60.0f, 0.5f, 1.0f, 0xffff0000};
But it generates syntax errors. Why?

Sorry for my English.
Tnx.



0
Comment
Question by:rv_man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 7042152
This syntax is similar to an INITIALIZER and is only legal in a DECLARATION, not as an ASSIGNMENT.

You could try:

CUSTOMVERTEX new_Vertices[myarraysize] = {60.0f,  60.0f, 0.5f, 1.0f, 0xffff0000};
0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 7042157
Try

CUSTOMVERTEX v =  {60.0f,  60.0f, 0.5f, 1.0f, 0xffff0000};

new_Vertices[0] = v;
0
 
LVL 30

Expert Comment

by:Axter
ID: 7042170
If you want to initialize the entire array, you can try the following:

const int myarraysize=3;
CUSTOMVERTEX new_Vertices[myarraysize] = {
{60.0f,  63.0f, 0.5f, 1.0f, 0xffff0000},
{61.0f,  64.0f, 0.5f, 1.0f, 0xffff0000},
{62.0f,  65.0f, 0.5f, 1.0f, 0xffff0000}
};
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question