newb12345
newb12345

Reputation: 17

How would one replace a vector with a linked list c++

I have a code with a template class and a few data members, the code for vector looks like this

std::vector<Check> ck(100);

how would one go about making this into a linked list?

Upvotes: 2

Views: 538

Answers (1)

juanchopanza
juanchopanza

Reputation: 227390

Like this:

std::list<Check> lck(ck.begin(), ck.end());

std::list is a doubly-linked list.

If you want a singly linked list, you can use std::forward_list:

std::forward_list<Check> lck(ck.begin(), ck.end());

Upvotes: 3

Related Questions