I have some simple hypothetical static class in C++:
#ifndef __STAT_H_
#define __STAT_H_
class Stat {
private:
static vector<int> v;
public:
static void add_num(int num);
static void clear_nums();
static void get_count();
};
#endif
And the ccp file is so:
#include "Stat.h"
vector<int> v;
void Stat::add_num(int num) {
v.push_back(num);
}
void Stat::clear_nums() {
v.clear();
}
int Stat::get_num_count() {
return v.size();
}
Now when I include in main.cpp file "Stat.h" and try to use some static method:
Stat::add_num(8);
the error during compilation is
undefined reference to 'Stat::add_num(int)'
What can be the problem in this case? Thank you.
EDIT: sorry about addresses vector, it should be v there