shell cartesian product of lines between 2 files

C++
$ cat file1
a
b
$ cat file2
c
d
e
$ join -j 2 file1 file2
 a c
 a d
 a e
 b c
 b d
 b e
Source

Also in C++: