How do I name a variable using a function parameter? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do I name a variable using a function parameter?

So I am making a game and everything is made out of shapes so I made a function for that you need to name a variable for it to be valid (In sfml an object is a variable.) It needs a name so I made a parameter that is for the naming. that doesn't work what do I do now?

26th Nov 2019, 3:03 PM
doonv
doonv - avatar
4 Answers
+ 1
I got it. Thanks.
26th Nov 2019, 3:34 PM
doonv
doonv - avatar
+ 4
You should show us the code, otherwise we would have to guess what might be the problem.
26th Nov 2019, 3:20 PM
HonFu
HonFu - avatar
+ 1
Is it possible to name variables using function parameters? That was the question
26th Nov 2019, 3:22 PM
doonv
doonv - avatar
+ 1
The function parameters have names already. Or do you mean, you want to pass in strings that are supposed to be referenced in the function like variable names would? If you showed us your code, someone might come up with a less complicated way to accomplish what you want to do. If you leave me guessing, a mapping type sounds like it might do what you want. Read up on it here: https://www.moderncplusplus.com/map/
26th Nov 2019, 3:30 PM
HonFu
HonFu - avatar