PDA

View Full Version : Template Class Dynamic Array [c++] How to...



Izumi_87
November 9th, 2008, 03:27 PM
Hello!
I'm learning C++ right now, but I just came across something that I have little to no idea how it should be done.
We have a template class that is a dynamic array. (class DynArr for example) I pretty much know how to index the elements inside of it, add a new element at the end of the array, make the constructor and the destructor, but how am I supposed to write the following:
0. a template constructor for initializing by another such array with any type of elements
1. concatenation of two string arrays
2. searching of an element within the array
3. operator << and >>
4. operator=
5. operator > < for lexicographic comparison

And after all this is done, how can we make a template specialization for char, which uses string.h's functions?

dribeas
November 9th, 2008, 07:33 PM
I'm learning C++ right now, but I just came across something that I have little to no idea how it should be done.
0. a template constructor for initializing by another such array with any type of elements
1. concatenation of two string arrays
2. searching of an element within the array
3. operator << and >>
4. operator=
5. operator > < for lexicographic comparison

And after all this is done, how can we make a template specialization for char, which uses string.h's functions?

This sounds horribly close to homework. This forum is not devoted to solving your homeworks. Try to work it out, and once you run into a problem that you cannot solve or you don't understand, ask again. You will get answers to your programming problems or doubts, but don't expect solutions to homeworks.