• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Good Website with Templated Linked List (C++)

ViRaLRuSh

Golden Member
Looking for some website that will have a linked list with templates and a driver program. I recently did a linked list with an array, but now would like to learn how to do so with templates. Functions included would be retrieve item, delete, add, etc. Thanks in advance, and no, this isn't homework, it's for personal pleasure.
 
I'd recommend http://www.stlport.org/ but it might be a little overkill. STLPort is a "free" version of the Standard Template Library (STL). STL includes a lists amongst other things. It might be overkill because there is A LOT of stuff there (in the list interface alone).
 
I've been a bystander here for a long time, but this is my first post 🙂

If your intention is to learn about templates in general, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vcrefTemplates.asp to learn about function templates and class templates.

If you are looking to work with containers, I highly recommend learning the C++ Standard Library (formerly known as STL). Everything you need is there and very fast. MSDN has great information at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/HTML/stdlbhm.asp

A quick sample of a vector is:


int main(void)
{
// declare a vector (a list or variable array) of numbers
vector<long> numbers;

for (long a = 0; a < 100; ++a)
{
// add a number to the end of the vector
numbers.push_back(a);
}

vector<long>::iterator it(numbers.begin());
while (it != numbers.end())
{
// deference the iterator to get the value at that position
cout << *it << endl;

// go to the next position in the vector
++it;
}

return 0;
}

🙂
 
Back
Top