i was in my programming class today and somebody opened up a .jpg file and the teacher went off. she said that you can get infected by a virus by opening any file and that viruses attatch themselves to any files they come into contact with. a couple of the kids argured with the teach on this, but she seemed pretty sure and said some stuff about how many years she'd been working in IT and that was the end of the discussion.

i had thought it was only executable files. and that you could only get infected from a normal file the file had something like a macro in it(like those old ones that exploited ms office) and you opened it with a program that could execute that macro... is it possible for a file, like a jpg, to have a viurs or worm hidden in it, like fused with the file, or would there have to be some kind of executable in the same folder with the jpg and that executable would be run by the macro when you open the jpg. and do viruses attatch themselves to all files or just executables?