I do not see why you would want this over any of the stl containers, or 3rd party libraries like boost or just something you found on github.
You aren't gonna learn by creating something that doesn't solve a problem, you will only learn how to give yourself more problems. In programming nobody will make fun of you for taking shortcuts by depending on code that you didn't write (especially for wheel-like things like containers), and the less code you write, the less possibility that you will make a mistake (sure you should learn, but do it for a reason, and if there isn't, just read how its done and say "huh so that's how it works").
First problem is that you are returning a reference, 2nd is you created a reference object that doesn't reference anything and you are trying to use it, 3rd you return a bool, 4th you are looping 6 times but there are only 3 elements
how is your code getting past this please compile your code in debug when debugging.
I think the "this" variable could help you if you want to return the current array BUT this doesn't make sense because you can just create a function that inserts a range of elements and just forget the setUnion, and your current logic is flawed since how could there be more items inside of an array than itemCount when the items in an array cannot be over itemCount (it could work, just doesn't make sense). Also where is "reserve" or "insert" defined how can it affect ArraySet's memory if it was inside of SetInterface?
I think you should study harder on practical programming and just get the job done in the best way possible focusing on KISS(keep it short and simple), readability, and usability.
nitpicks: you use namespace std but you still use std::string, just make a choice and stay consistant. "ArraySet" is confusing, is it more like a std::set or an std::array? The name "setUnion" doesn't make sense it's just a "merge" there is an <algorithm> function called std::set_union and it does something quite different, and there is also std::merge that works for stl containers.
// end ArrayBag
is obsolete/typo, also a good reason to avoid superfluous comments.
and what does this mean, why didn't you just delete this if it is dead code?
//#include "ArraySet.cpp" |
edit: also from my understanding everything with templates requires all the code to be in headers, so that means it would make more sense for the function to just be defined inside the class if you can.