Is there a way to declare/create a variable after a program is executed is with a name that is obtained from data obtained after the program is executed? For example, if I had:
Is a factory model what you want? Do you want a scripting environment?
I think you need to be more clear and precise with your problem. In your previous topic, I am completely lost with what you are trying to accomplish, it doesn't seem like a something teacher would give homework for.
there are many ways. You can use a union of the types for a very simple approach. You can use a class template. You can use a class with a "what am i" member. You can use void *. And those are just a few ways to do it. You can just use a wad of bytes (array of unsigned char for example) and jam the data into it with pointer magic.
names are the weird part. You can't write the program to reference variables you have not created yet; it won't compile. But you can store the data and use it, and have a 'name' on it that you can search for, etc. so you can't do this:
myvarcreate(); //creates fruit variable
fruit = 10; // undeclared at compile time, no good.