I split a ring buffer class into RingBuffer.h, with the declaration template <typename T, size_t N> class RingBuffer, and RingBuffer.cpp with the member function definitions, the way I do for ordinary classes. Every file compiles, but linking fails with an undefined reference to RingBuffer<unsigned char, 64>::push(unsigned char).
Moving the definitions into the header makes the error go away. Why does a template behave differently from a normal class, and is putting everything in the header the only option?




