#include <iostream.h>
class cell
{
int static amount;
int number;
double meaning;
public:
cell(double meaning = 0.0)
{
amount++;
this -> number = amount;
this -> meaning = meaning; }
void display (void)
{
cout << "\nnumber = " << this->number;
cout << " amount = " << this->amount;
cout << " meaning = " << this->meaning;
}
};
int cell::Amount = 0;
void main(void)
{ cell A;
A.display();
cell B(200.0);
cell C(300.0);
B.display();
C.display();
}
Выводит результат:
Number = 1 Amount = 1 Meaning = 0
Number = 2 Amount = 3 Meaning = 200 // <-- ??
Number = 3 Amount = 3 Meaning = 300
не понимаю почему во второй строке значение amount равно 3, а не 2, как должно быть?
пробовал на двух разных компиляторах