I am working on homework where I have to write a template and then implement the template into a driver. Unfortunately, I’m receiving an error when compiling. I’m just beginning to learn the more complex aspects of C++, and I have no idea how to resolve this problem.
/tmp/ccdvvLpF.o:main.cpp: (.text$_ZN11LinkedQueueISsE7enqueueERKSs[LinkedQueue, std::allocator > >::enqueue(std::basic_string, std::allocator > const&)]+0x4a): undefined reference to LinkedQueue<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::number'LinkedQueue, std::allocator > >::number’
/tmp/ccdvvLpF.o:main.cpp:(.text$_ZN11LinkedQueueISsE7enqueueERKSs[LinkedQueue<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::enqueue(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x66): undefined reference to
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: /tmp/ccdvvLpF.o: bad reloc address 0x66 in section `.text$_ZN11LinkedQueueISsE7enqueueERKSs[LinkedQueue, std::allocator > >::enqueue(std::basic_string, std::allocator > const&)]’
collect2: ld returned 1 exit status
Thanks.
static int numberis never defined. Add the following definition outside of your class.staticmembers are special,static int numberinside the class is only a declaration and not a definition. The reason for this is because headers are usually included in multiple translation units, so C++ forces you to define them outside of the class usually in a cpp file so that you do not get multiple definition errors.