Contrary to @tikend, files are not saved in their old path and just marked as deleted. Instead, files are moved to the
$Recycle.Bin directory at the root of drive. Inside, there are folders named something like
S-1-5-21-4284498480-1431815607-1764836822-1001 (actual example)*, and inside those are the deleted files.
Why we can have two files with same name in Trash? Because their names are mangled. Instead of
sumthinFunny.cpp we have
$RYDITY2.cpp. Those identifiers make it possible to have two files with the same name.
How does Widows know where the file was deleted from? It stores the file’s metadata (like path in question, file attributes, and so on) in the
$IYDITY2.cpp file. Inside, there is path to the original directory.
By the way, if you open
$Recycle.Bin from Windows Explorer, it appears empty. You can see it if you mount drive from Linux, or through a other file manager, like Total Commander.
BTW2: While file names are mangled into $RYDITY2.cpp like form, when you open their properties, you get something that looks like UUID: i.imgur.com/oA8rziH.png
* This folder name is the SID of the user who deleted the file.
Edited in order to bring comments' wisdom here.