Wheel Encoder Class Error

Hello,

I am trying to make a Wheel Encoder class and I've run to the following error:
in Arduino IDE:

C:\Users\STEFAN~1\AppData\Local\Temp\buildcb033d5e16aa4abe4474a2cd54206393.tmp\libraries\MyEncoder\MyEncoderLib.cpp.o: In function `MyEncoder::LWheelSpeed()':

C:\Users\stefanito21\Documents\Arduino\libraries\MyEncoder/MyEncoderLib.cpp:29: undefined reference to `MyEncoder::coder'

C:\Users\stefanito21\Documents\Arduino\libraries\MyEncoder/MyEncoderLib.cpp:29: undefined reference to `MyEncoder::coder'

C:\Users\STEFAN~1\AppData\Local\Temp\buildcb033d5e16aa4abe4474a2cd54206393.tmp\libraries\MyEncoder\MyEncoderLib.cpp.o: In function `MyEncoder::RWheelSpeed()':

C:\Users\stefanito21\Documents\Arduino\libraries\MyEncoder/MyEncoderLib.cpp:34: undefined reference to `MyEncoder::coder'

C:\Users\stefanito21\Documents\Arduino\libraries\MyEncoder/MyEncoderLib.cpp:34: undefined reference to `MyEncoder::coder'

C:\Users\STEFAN~1\AppData\Local\Temp\buildcb033d5e16aa4abe4474a2cd54206393.tmp\libraries\MyEncoder\MyEncoderLib.cpp.o: In function `MyEncoder::MyEncoder(int, int)':

C:\Users\stefanito21\Documents\Arduino\libraries\MyEncoder/MyEncoderLib.cpp:13: undefined reference to `MyEncoder::coder'

C:\Users\STEFAN~1\AppData\Local\Temp\buildcb033d5e16aa4abe4474a2cd54206393.tmp\libraries\MyEncoder\MyEncoderLib.cpp.o:C:\Users\stefanito21\Documents\Arduino\libraries\MyEncoder/MyEncoderLib.cpp:14: more undefined references to `MyEncoder::coder' follow

collect2.exe: error: ld returned 1 exit status

in Visual Studio IDE:

Compiling 'MyEncoder' for 'Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)'
MyEncoder.cpp.o:In function `sense()
MyEncoder.ino:distance()
MyEncoder.cpp.o:In function `__static_initialization_and_destruction_0
MyEncoder.ino:MyEncoder(int, int)
collect2.exe*:error: ld returned 1 exit status
Error creating .elf

Here is my .h file

/*
 Name:		MyEncoderLib.h
 Created:	2/28/2016 12:33:18 PM
 Author:	stefanito21
 Editor:	http://www.visualmicro.com
*/

#ifndef _MyEncoderLib_h
#define _MyEncoderLib_h

#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif

#define LEFT 0
#define RIGHT 1
class MyEncoder
{
public :
	MyEncoder(int InterruptPinLeft, int InterruptPinRight);
	float distance();
	static void LWheelSpeed();
	static void RWheelSpeed();
private:
	int lastSpeed[2],count;
	static const float ppr, pi, diameter, circumference;
	static long coder[2];
};

#endif

and my .cpp file

/*
 Name:		MyEncoderLib.cpp
 Created:	2/28/2016 12:33:18 PM
 Author:	stefanito21
 Editor:	http://www.visualmicro.com
*/

#include "MyEncoderLib.h"

MyEncoder::MyEncoder(int InterruptPinLeft, int InterruptPinRight)
{
	attachInterrupt(digitalPinToInterrupt(InterruptPinLeft), LWheelSpeed, CHANGE);
	attachInterrupt(digitalPinToInterrupt(InterruptPinRight), RWheelSpeed, CHANGE);
	coder[LEFT] = 0;
	coder[RIGHT] = 0;
	lastSpeed[LEFT] = 0;
	lastSpeed[RIGHT] = 0;
	count = 0;
}

const float MyEncoder::ppr = 20.0f;
const float MyEncoder::pi = 3.1416f;
const float MyEncoder::diameter = 0.0635f;
const float MyEncoder::circumference = pi * diameter;

void MyEncoder::LWheelSpeed()
//void LWheelSpeed()
{
	coder[LEFT] ++;  //count the left wheel encoder interrupts
}
void MyEncoder::RWheelSpeed()
//void RWheelSpeed()
{
	coder[RIGHT] ++; //count the right wheel encoder interrupts
}

float MyEncoder::distance()
{
	count = (coder[LEFT] + coder[RIGHT]) / 2;
	return circumference * count / ppr;
}

Can anyone help me??

P.S. Sorry for the long post

Why is coder[] declared static? Every instance of the class needs it's own coder array.

When the interrupt happens, which instance of the class should know about the fact that the interrupt happened?

If you think that you will only ever have one instance of the class, then you have to ask yourself what the advantage of a class is. If there will be multiple instances, then you need to tell us how the interrupt handler is going to know which instance to notify.

Its Arduino.h, not arduino.h

Use <>, not "" if including library header files. "" searches the current directory first.

PaulS:
Why is coder[] declared static? Every instance of the class needs it's own coder array.

When the interrupt happens, which instance of the class should know about the fact that the interrupt happened?

If you think that you will only ever have one instance of the class, then you have to ask yourself what the advantage of a class is. If there will be multiple instances, then you need to tell us how the interrupt handler is going to know which instance to notify.

I will have only one instance of a class. The only purpose of the class is that I won't have all my code in one sketch. if I can't find a way around I will put it in my sketch. I've change the coder[] and I get the following error

error: invalid use of member 'MyEncoder::coder' in static member function

MarkT:
Its Arduino.h, not arduino.h

This code is generated automatically from visual studio 2015.

MarkT:
Use <>, not "" if including library header files. "" searches the current directory first.

I've changed it and still got the same errors.

The only purpose of the class is that I won't have all my code in one sketch.

You can create a header file that does NOT contain the word class.

You can develop functions in a source file without defining a class.

This code is generated automatically from visual studio 2015.

Even Microsoft, which sucks when it comes to understanding that Arduino.h and arduino.h are different files ALWAYS gets Visual Studio right.

I've change the coder[] and I get the following error

You can only access static data from static methods.

Make life easy for yourself. Dump the class.