I've got a basic question. Is it possible to number objects automatically? So for example if I have a class 'item' and in the main I have
item item1(weight, length);
item item2(weight, length);
and in the constructor of the item class we assign the weight and length to the corresponding variables.
class item {
public:
item(int w, int l){
weight = w ;
length = l ;
itemnumber = ??? ;
private:
int weight;
int length;
int itemnumber;
};
But on top of that I also want a variable itemnumber. This itemnumber should be 1 the first time I create an object (so 1 for item1) and 2 the second object created (item2) and so on. But I don't want to pass it as a parameter. So basically what should I put instead of the '???' in my code ?
Is this possible?