If you were to give me an assignment

...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? ;)



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.
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!
After that, you could try with an associative container

And you should add some more 'plz' and '?'
Last edited on
How about writing a string tokenizer. You could make it accept basic_string<class T>'s so that it would support strings or wstrings.
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.