That is correct. When you ssh into a machine you get a whole new user session.
How are you launching that program after boot up?
If it were me I would arrange to have it start automatically at boot time by creating a systemd service file for it.
Then all the output messages would be sent to the system log. /vat/log/syslog
From where they can be read from another login session.
Alternatively redirect the programs output to a log file of it's own. Be careful that file does not grow huge and eventually fill your SD card.
I wrote some instructions for using systemd to start applications at boot time here: viewtopic.php?t=138861
Memory in C++ is a leaky abstraction .