(If you don't feel like explaining, please tell me what I need to read up on. Derived classes? Polymorphism?).
I have got this assignment from school, in which we are handed a main.cpp file and we are supposed to write the class for it.
But there's a few thing about classes that I don't understand. Here's a bit of code:
Product pineapple = Product( "Pineapple" ); Product milk = Product( "Milk", 7 ); Product mustard = Product( "Mustard", 35, "Very exclusive and good" ); cout << Product::getNumberOfProducts() << endl;
I understand the override constructor function part.
But why have my teacher defined the class like:
Product pineapple = Product( "Pineapple" );
and not like:
Product pineapple( "Pineapple" );
And the second question. How can he count the number of products from this function, it's not even a declared class.