-1

Trying to compile:

Glider.h:

class Glider
{
public:

static int RuleNumber;

static void SetRuleNumber(const int RuleNmb);
};

Glider.cpp:

#include "Glider.h"

void Glider::SetRuleNumber(const int RuleNmb)
{
Glider::RuleNumber=RuleNmb;
return;
};

Produces:

1>Glider.cpp
1>Glider.obj : error LNK2001: unresolved external symbol "public: static int Glider::RuleNumber" (? 
RuleNumber@Glider@@2HA)
fatal error LNK1120: 1 unresolved externals

What is wrong with this code? Can't figure it out. Using newest Visual Studio.

Mat
  • 195,986
  • 40
  • 382
  • 396
Smoksul
  • 21
  • 2

1 Answers1

0

Adding

 int Glider::RuleNumber=0;

in Glider.cpp solved the issue although I don't really know why would it change anything.

Smoksul
  • 21
  • 2