There are so many things wrong here I don't know where to start....
Let's start here:
#include ex.h
That's not how you include something. Try
#include "ex.h"
Next, the ex.cpp also needs to include the ex.h.
And ex.h needs to include Arduino.h
void foo::test {
Is not how you define a function. Try
void foo::test(){
And because now it's private and you declare it in ex.h like
public:
void foo::test();
const int a = 0 ;
//....
a = 0 ;
How do you think you can assign a value to a const? That's the whole idea of a const, you can't...
Then off to the more complex matters. ex.cpp is compiled completely separate of file.ino. It has therefor no knowledge about it's use in file.ino and what variables are there. If you want to indeed change a variable over there you need to tell the compiler it will exist by putting in the ex.h
extern int a; //and you have to make a a int instead of a const int because that can never work.
But really, why do you want to do this. It's a very ugly way of doing it. The class can now only work on that single variable a, no matter how many objects of class foo you have. And it relies on YOU declaring variable a in your sketch. Why is a not part of the object? So in ex.h
class foo {
public:
void test ();
protected:
int a; //which clearly needs a better name
} ;
And if you really want to do something with a variable in the sketch (because the variable has no 1 to 1 relation with the object, pass it by reference. Google it to see what it means 
in ex.h
class foo {
public:
void test (int& a) ;
} ;
In ex.cpp
void foo::test(int& a) {
a = 0 ;
}