я написал класс, как показано ниже:как определить статическую переменную общего типа
template <class T>
/* Abstract class for stack n queue */
class StacknQueue
{
public:
StacknQueue(int = 10);
virtual int insert(const T&) = 0;
virtual int remove(T&) = 0;
virtual void display() = 0;
int isEmpty() const {return top == -1 || front == -1 || front > top ;}
int isFull() const { return top == size - 1 ;}
//virtual int isQEmpty const() = 0;
//virtual int isQFull const() = 0;
void initialize();
static int flag;
static int size;
//int rear;
static int front;
static int top;
static T *stknqPtr ;
};
при попытке определить переменную stknqPtr вне класса, как показано ниже:
template <class T>
T StacknQueue<T> :: stknqPtr = new T[size];
его дает мне ошибка:
error C2040: 'stknqPtr' : 'float' differs in levels of indirection from 'float *'
Я новичок в C++, кто-нибудь может предложить мне, как действовать.
Заранее благодарен
Нет, вам не нужны явные экземпляры для каждого типа, http://ideone.com/P4AyH2 – vsoftco
Спасибо, это сработало – anonymous
@vsoftco - Вы на месте - я должен что-то забыть. Подумайте, это стерлось. –