|
| binarysolo (14) | |||
| Hello, how to make a template class with an array of X items So far I have:
Also, how would I create a Quad object to store 4 strings: "Hello" "World" "How are" "You?"? | |||
Last edited on | |||
| Bazzy (4120) | |
Replace int with T and write the constructor accordingly. | |
| binarysolo (14) | |
| On my array? And what would I be adding to the constructor, exactly? | |
| jsmith (3807) | |||||
The only data member your class needs is
You do not need n, i, small, or list. I do not know what a "general constructor" is. Bazzy is suggesting (I think) that you write (at a minimum) the following constructor:
getSmallest() should not take any parameters; it should reference the "elements" data member. getSmallest() is also most simply implemented with std::min_element() [see <algorithm>]. print() should print the four elements, not the smallest element. This can be accomplished with a simple for() loop. | |||||
| binarysolo (14) | |
| Thanks for the help! | |
This topic is archived - New replies not allowed.
