Was this done from your comp or did they use another comp? How do you know they hacked your account? Did person B tell you that they received these emails?
You could always follow the below link and post the results here to see if you comp is infected with anything that would be able to allow then to do this.
http://www.computerhope.com/forum/index.php/topic,46313.0.htmlChange you password to something really strong. Make sure it has a combination of letters and numbers. Some times you can even use special characters like the "@" in your passwords if so use them as well. I can't remember if Yahoo passwords are case sensitive but if they are be sure and mix the letters with upper case and lower case.