I am developing C++ on Netbeans 7.1 on Ubuntu 11.04. I was wondering if someone could tell me why Stack fs(5); is seen as an undefined reference to to `Stack::Stack(int)'. Why is it not seen as a class with float used for T?
#include <iostream>
using namespace std ;
template <class T>
class Stack
{
public:
Stack(int = 10) ;
~Stack() { delete [] stackPtr ; }
int method1(const T&);
int method2(T&) ;
int method3()const { return top == -1 ; }
int method4() const { return top == size - 1 ; }
private:
int attribute1 ;
int attribute2 ;
T* stackPtr ;
} ;
using namespace std;
int main()
{
// This line gives the error message "undefined reference to `Stack<float>::Stack(int)'"
Stack<float> fs(5);
return 0;
}
Thanks, Peter.