operator- is quite ... interesting.
First, as implemented, it does NOT do what you say it does.
Let me give a different example:
If A = [z, a, b, c] and B = [b, c], then A - B
should be [z, a], but
in your case it would be [a, z]. This is because of the sort. Don't
sort the elements.
(Don't sort them for another reason: you swap characters, but you
compare
strings to determine if you should swap.)
With a couple more member functions and constructors, you could
make this function really trivial. For example, if you had an operator+=
that took a char, you could just do:
1 2 3
|
stringarray temp;
temp += char_to_add_from_bag_1;
|
instead of managing the internals of the object yourself.