c++ - Create a vector of pointers to abstract objects -
i'm sure there's better way this.
i'm trying create class hashtable
given size @ instantiation, can't given size @ design time, can't use array internal representation of table, far know.
so here's i'm trying do:
#include <vector> #include <iostream> #include "nodes.h" using namespace std; template <class t> class hashtable{ protected: vector<* tablenode<t>> mytable; //other protected methods go here public: hashtable(int size){ mytable = vector<* tablenode<t>>(size,null); } //the rest of class };
from i've seen, vector best data structure use here, because let me give size in constructor, , lets me use mytable[index]
style notation access contents. however, vs2010 doesn't use of vector<* tablenode<t>>
, can't blame it. so, how create array or vector or whatever of pointers tablenode<t>
elements?
move asterisk around:
vector<tablenode<t>*> mytable; mytable = vector<tablenode<t>*>(size,null);
Comments
Post a Comment