Answer the question
In order to leave comments, you need to log in
C++ Why is static variable not created?
Such an error:
error: C2065: cout
:
class counter
{
public:
static int count;
void setcount(int i)
{
counter::count = i;
}
void showcount ()
{
//На эту строку ошибка C2065: cout: Ґ®Ўкпў«Ґл© Ё¤ҐвЁдЁЄ в®а
cout << counter::count << " ";
}
};
int counter::count; // определение count
int main()
{
counter a, b;
a.showcount (); // выводит 0
b.showcount (); // выводит 0
a.setcount (10); // установка статического count в 10
a.showcount (); // выводит 10
b.showcount (); // также выводит 10
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question