A computer virus is a type of malware that, when executed, replicates by inserting copies of itself into other files; when replication succeeds, the files are then said to be "infected.”
Viruses can either copy themselves directly into executable files, or can infect files that are opened/processed by the target executable (e.g. PDF documents or Flash applications).
Viruses use a variety of infection mechanisms to replicate into new hosts (often employing anti-detection strategies to evade antivirus software), and can perform many different types of actions once they have infected the hosts (e.g. stealing disk space and CPU time, accessing private information, corrupting data or logging keystrokes). Not all viruses carry a payload or attempt to hide themselves; the defining characteristic is that viruses are self-replicating.