A computer virus is a program, usually small or very small in size, which has the capacity to infect and multiply, and having a harmful function (the payload).
The infection function enables the virus to infiltrate program files, data files using a script language, or the part of removable media of the hard disk containing a small program (the boot sector). When accessing these programs or this sector, the virus code executes stealthily (the multiplication phase during which it infects other files), and then visibly (when the harmful function is activated).
The harmful function can be triggered by a wide range of factors depending on the virus (after n replications, at a set date, during the execution of certain precise tasks, etc.). It may be limited to displaying an annoying message, or more generally, lead to serious disturbances of the computer (slowed operation, deletion or corruption of files, hard drive formatting etc.). Viruses are thus parasitic programs that have to be hosted within other files (or on the executable sector of the disk).
The word virus is often used incorrectly for other harmful programs (malware), and in particular, worms.