testing.

closed account (jGAShbRD)
im getting an error when i was trying to test my code i got a main.cpp and a class
main.cpp:5:13: error: use of
undeclared identifier 'T'
FastQueue<T> testing;
^
main.cpp:6:3: error: use of
undeclared identifier 'testing'
testing.enqueue(5);
--------------------------------------------------------------------
#include "FastQueue.h"
#include <iostream>

int main() {
FastQueue<T> testing;
testing.enqueue(5);
std::cout << testing.size() << std::endl;
std::cout << testing.capacity() << std::endl;
}
------------------------------------------------------------------
template <typename T>
class FastQueue
{
public:
FastQueue(); //constructor
void enqueue(const T & element);
----------------------------------------------------------------------
template <typename T>
void FastQueue<T>::enqueue(const T & element){stuff}
...
-------------------------------------------------------------------
You have to put an actual type in the <T> when declaring an object. FastQueue<int> testing; for example.
Topic archived. No new replies allowed.