I'm new to C++, and I'm trying to use a static member variable as a "dictionary" in a translation program.
I have two files, alphabet.h, which looks like this:
#ifndef ALPHABET_H
#define ALPHABET_H
#include <map>
#include <vector>
class Alphabet {
public:
typedef std::vector<std::string> letterType;
typedef std::map<std::string, letterType> alphabetType;
alphabetType getAlphabet();
private:
static alphabetType m_alphabet;
};
#endif
And alphabet.cpp, which looks like this:
#include "alphabet.h"
static Alphabet::alphabetType m_alphabet = {{"ὁ",{"o"}}};
Alphabet::alphabetType Alphabet::getAlphabet() {
return Alphabet::m_alphabet;
}
For some reason when I attempt to compile, I get an error from g++.
In function Alphabet::getAlphabet[abi:cxx11]()':
alphabet.cpp:6: undefined reference to
Alphabet::m_alphabet[abi:cxx11]'
collect2: error: ld returned 1 exit status
I would appreciate any insight into what I'm doing wrong.