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

For looping

Posted on 2002-03-15
Last Modified: 2010-04-01

I would like to set many pictures to control boxes using a loop, but don't know how to do this.

I want to set m_Pic1 - mPic12 and pic1 - pic12, but I don't know the function to evaluate this.

for(int i; i<12; i++){

// How do I set variables m_Pic1 and pic1 to increment?



Anyone help me on this?  Thanks in advance.
Question by:KAbbott

Expert Comment

ID: 6868038
make an array of them, and loop through that.
alternately, make an array of pointers to all of them and loop through it instead; this will be easier in this situation I think...


Accepted Solution

pagladasu earned 20 total points
ID: 6868372
Make these two #define statements at the begining of your program
#define m_Pic(x)     m_Pic##x
#define pic(x)          pic##x

then use it as follows:
for(int i = 1; i<13; i++){

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

790 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