Beginner's Syntax Question

Assuming I have 3 variables v1, v2, v3, typically in VB I would be able to do stg like that to initialize them:

for a=1 to 3

v & a = x

next a

How do I do that in c++ assuming I cannot use v[1], v[2]...
The reason I am asking is that I have some variables attached to some controls, and the Class Viewer does not let me declare [] as part of a variable name.

Thanks & joyeux noel.
Who is Participating?
The_BrainConnect With a Mentor Commented:
Thanks man.

There is no Way of doing that in C++, you have to use arrays.

for (int p=0; p<3; p++)

this in way that you are asking is not an option in C++; sorry.

Regards Brain.
decornezAuthor Commented:
Sorry Brain,

unfortunately I know how to do that as well.
There's got to be a way somehow....
I'll leave this question open to see if anybody has any suggestions.

Thanks for the input and happy holidays.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

>> There's got to be a way somehow....
decornez, the C/C++ languages do not allow you to dynamically construct variable names.  No way around it due to the internal working of the languages.

You can write:
    v1 = v2 = v3 = x;

Or you can use arrays (as suggested by The_Brain).
if my answer is correct as it probably is can I have the points for it? if so could you send me an E-mail so that I can answer the question so that I may collect the points? or is this question gonna be one of those one that hang around to rot. :)
decornezAuthor Commented:

Merry Christmas. I'll give you the points since it seems that what I am trying to achieve is not doable anyway. Just post a comment and they are yours.

decornezAuthor Commented:
Oooops, I meant post an answer (not comment) & they are yours.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.