Code:
class Fruit
{
public:
string name;
int quantity;
}apple = {"Apple", 5}, pear = {"Pear", 3}, peach = {"Peach", 2};
Fruit list[100];
Is there a way to store each Fruit object into list[100] without typing out "list[0] = apple, list[1] = pear....etc"?
And, is there a way to use sizeof on a class, to count the number of objects it has? So I can make list[] hold the same number elements as Fruit has objects.
I'm trying to code in a way so when I add more objects later down the road, I will only have to initialize them in their class. Rather than have to do that, and change array sizes, and values and all that.
Much appreciated,