Вопрос

My Problem is the following:

I have a class with static counter. I set this counter as volatile because I use this variable in multithreaded environment.

class.h

class myClass
{
 public:
 volatile static int mCounter;
 (...)
};

class.cpp

int myclass::mCounter = 0;

In CPP file, I initialize it, and I obtain the following compilation error:

'mCounter' : redefinition; different type modifiers

Why ?

Thanks in Advance.

Это было полезно?

Решение

You need to repeat the "volatile" on that line as well.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top