Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 07-17-09   #1 (permalink)
Audiophile
 
Gnarly's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Missouri
Posts: 2,198

Rep: 113 Gnarly is acknowledged by manyGnarly is acknowledged by many
Unique Rep: 91
FAQs Submitted: 2
Trader Rating: 4
Default Simple C++ question, is this possible?

So I can type

int a1 = 1;
int b1 = 1;
and so on...

Is it possible to have a loop that would create as many ints (or any other type) with custom labels?

Something like...
int x = 0;
string str;
while ( x < y)
{
str = function_that_appends_x's_value_to_letter(x);
int "str" = 0; //this is my main question, I know this wouldn't compile.
x++;
}

I feel like the answer is staring me in the face using dynamic arrays, pointers, or something OR there would never be a real use for such a thing. I'm trying to make a puzzle of sorts, and having this functionality would make the code more "fun" to read.
__________________
System: Promise of Stress
CPU
Q9450
Motherboard
GIGABYTE GA-EP35-DS3L P35
Memory
4x2gb G.Skill DDR2 800
Graphics Card
evga gtx 260 192
Hard Drive
640gb WD + 750gb Samsung
Sound Card
Flashed Chaintech AV710 for optical out
Power Supply
Corsair HX520W
Case
Coolermaster CM690
CPU cooling
lapped Tuniq Tower
OS
Vista Business x64
Monitor
24" Samsung
Gnarly is offline   Reply With Quote
Old 07-17-09   #2 (permalink)
With great difficulty
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,210

Rep: 614 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 370
FAQs Submitted: 6
Trader Rating: 5
Default

You want to use a map, where you can map a string identifier to an int value
__________________
System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 07-17-09   #3 (permalink)
Audiophile
 
Gnarly's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Missouri
Posts: 2,198

Rep: 113 Gnarly is acknowledged by manyGnarly is acknowledged by many
Unique Rep: 91
FAQs Submitted: 2
Trader Rating: 4
Default

Great, thanks for the help. It's difficult to google such things.
__________________
System: Promise of Stress
CPU
Q9450
Motherboard
GIGABYTE GA-EP35-DS3L P35
Memory
4x2gb G.Skill DDR2 800
Graphics Card
evga gtx 260 192
Hard Drive
640gb WD + 750gb Samsung
Sound Card
Flashed Chaintech AV710 for optical out
Power Supply
Corsair HX520W
Case
Coolermaster CM690
CPU cooling
lapped Tuniq Tower
OS
Vista Business x64
Monitor
24" Samsung
Gnarly is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 05:01 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.11654 seconds with 8 queries