Click here to Skip to main content
15,881,766 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Links to my code, did not use the code tags here because there are a lot of files... The links are in c++ syntax. This is my first post.

node.h
http://pastebin.com/3jrnNN5p
main.cpp
http://pastebin.com/LAa1tpi2
node.cpp
http://pastebin.com/GxYmne1L
bag.cpp
http://pastebin.com/Zup91snh
bag.h
http://pastebin.com/evdxtSx8

I have all of these files for my c++ homework and I am having trouble overloading the - and -= operators to use in my bags x and y. The homework states that we must do it like this;

For two bags x and y. The bag x-y contains all the items of x, with any items from y removed. For example, suppose that x has seven copies of the number 3, and y has two copies of the number 3 (ie 7-2 copies of the number 3). In the case where y has more copies of an item than x does, the bag x-y will have no copies of that item. The statement x -= y should have the same effect as the assignment x = x-y.

Does anyone know how this would be done? Maybe some examples using my code? Thanks, I do not wish for you to write the 2 overloading functions for me. If you are willing then by all means go ahead, but if you do try to explain it to me.
Posted
Updated 8-Mar-12 19:05pm
v2
Comments
Sergey Alexandrovich Kryukov 9-Mar-12 1:00am    
What's the question? Does anyone know how this would be done? The answer is "yes".
--SA

1 solution

It looks like you did not really got to the idea of the value of home assignment, not yet. Here is a hint for your: home assignments are very valuable. If you have to pay for education, please understand: this is perhaps most valuable part of your school activity worth paying for. If you do not do your home assignment 100% by yourself, this is the same as flushing money down the toiled. And you don't want it.

So, I suggest we give you another chance to use the opportunities your school gives you.

Good luck,
—SA
 
Share this answer
 
Comments
[no name] 9-Mar-12 1:55am    
Correct, polite and diplomatic.

I would have started with "Now listen here you little.......".
Sergey Alexandrovich Kryukov 9-Mar-12 2:48am    
Thank you very much.

Strange, some inquirers complain I "abuse" them or, say, "piss-off"; and this sort of people are pretty usual.

I cannot help amazing how deep a cultural clash can be. From time to time, I face people who cannot bear any criticism; even such thing as "Look, it won't work" may cause hysterical reaction like "How can you tell this to me?! I always had excellent grades in my school and my mom told be I was genius!.." :-) At the same time, I was educated in that kind of creative atmosphere where your best friend never misses a chance to dip your face in dirt (I mean, by challenging you), especially if you dare to claim that you deeply understand some field, and I think this is perfectly normal, as the criticism is one of the main driving forces of the progress and culture. A decent person is expected to take the challenge and proof one's point or admit the failure, which is usually considered as respectful enough.

--SA
nv3 9-Mar-12 4:16am    
How true! I am watching the questions section only since a short time, but I am amazed at how many school kids think, this website is just there to do their home work. And I also admire at the patience and politeness that some of you regulars have with those kids.
Sergey Alexandrovich Kryukov 9-Mar-12 9:08am    
Thank you very much.

Nevertheless, at this moment my answer has one vote of 1, down-voted. Someone still thinks my answer is rude, because I didn't do the home assignment for OP, as if I was obliged to...

--SA
nv3 9-Mar-12 9:53am    
Tried to express my opinion in a voting for your solution. Should have done that in the first place. Thanks again for all your work here. You guys do a fabulous job.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900