A node is a data type right? So I should be able to create a vector of that dataType? Or am I missing something or doing it wrong? Can I create a vector<node> nodeVector?
template <class Type>
struct node
{
Type info;
node<Type> *nextNode; //pointer to next node.
};
template <class Type>
class circularLinkedList
{
private:
Type * head; //head points to the first node.
Type * tail; //tail points to the last node,
int count;
circularLinkedList()
{
count = 0;
head = nullptr;
tail = nullptr;
}
circularLinkedList(int listSize)
{
count = listSize;
vector<node> nodes(count);
head = nodes.front();
tail = nodes.back();
}
void getValues(Type values[]);
}
Make that an uppercase T and it should work, but what's the point? nodes is an object local to the constructor function, so it will go out of scope and stop existing when that function returns. You probably want it as a private data member.
I can't figure out what you're up to with those pointers.
I have the vector to make future functions easier.
eg a function that adds a node, I can just reference nodes[i] in a loop for example.
You're not really making a linked list, though. The point of a list is that inserting elements in the middle is extremely fast. If you maintain a vector with the nodes, you lose that property. You may as well just use a vector.