I am very new to C++ and am trying to create a "Generic Class" that can take any input.
I need a way to store whatever input my class receives in either an Array or a Vector. I am however struggling to figure out how to do that.
I tried to do this in my .cpp File:
template<typename T> T data[5];
template<typename T> vector<T> vect;
This is what my Header File looks like:
#include <vector>
using namespace std;
template <class T> class Stack {
public:
void push(T x);
T peek();
T pop();
int size();
bool contains();
private:
vector<T> data;
};
But that is obviously not working, I am given to understand that what I am doing is not possible? How would I be able to create an Array or Vector that can store whatever my class receives?
I am quite new to this, so apologize for silly mistakes and or misunderstandings.