If you were to give me an assignment

Dec 18, 2008 at 11:03am
...involving templates, what would that be?
I have never worked with templates, but I feel it's something I can't avoid anymore. But I need some practice.
So if you have a suggestion for a nice little app that allows me to practise using templates, please write it here.






Instead of asking you to do my homework, I'm asking you to give me homework. How cool is that? ;)



Dec 18, 2008 at 12:37pm
Okay, how about this?
Write a class that implements a vector. It should be able to contain any type, and perform the following operations: resize, clear, add an element at the end, remove the element at the end, and, of course, get and set any element.
Dec 18, 2008 at 12:55pm
cna anyone plz help me?!?!?!?!! I need to maek progrm dat has a vector with ani tipe and it shod add and deleet elements.

can yuo post code? okay? plzz



Jokes aside, that's sounds a great exercise. Thanks!
Dec 18, 2008 at 1:05pm
After that, you could try with an associative container

And you should add some more 'plz' and '?'
Last edited on Dec 18, 2008 at 1:07pm
Dec 23, 2008 at 3:15pm
How about writing a string tokenizer. You could make it accept basic_string<class T>'s so that it would support strings or wstrings.
Dec 25, 2008 at 8:19pm
To exercise both function and class templates, try to implement a binary tree node class (containing generic data) and a binary tree toolkit that implements search, insertion, removal and traversal operations. For added fun, let the traversal functions implement a function pointer as a template parameter.
Topic archived. No new replies allowed.