We are supposed to declare the private member variable trackerCoordinates as an atomic. The .h was originally written like:
class Missile : public Attack, public Sea::Coordinates {
private:
bool hit = false;
Sea::FCoordinates trackerCoordinates;
I've tried to use the std::atomic like this:
class Missile : public Attack, public Sea::Coordinates {
private:
bool hit = false;
std::atomic<Sea::FCoordinates> trackerCoordinates;
Now, in the accompanying .cpp, in line 3, there's a new error, which gets resolved by undoing the std::atomic declaration.
Missile::Missile(Coordinates const & coordinates)
: Coordinates(coordinates),
trackerCoordinates(-1.f,-1.f) -- this line
{
}
The error says:
No matching constructor for initialization of 'std::atomicSea::FCoordinates' (aka 'atomic<TCoordinates>')
I do not know why that error happens and how to resolve it.
A bit more information: FCoordinates is a typedef of TCoordinates, which is supposed
to create coordinates given as a parameter like (x,y)
, and the TCoordinates constructor is noexcept declared.
Thanks in Advance for any help.