Yammers,
In order to get a connection from your PC to a Pi across the internet without some "cloud" server in the middle at least one end will need to be reachable from the internet, it will have a public IP address and preferably a domain name. Otherwise they cannot find each other.
If your Pi can be given a public IP address by your ISP you are good to go. You can access it via HTTP/HTTPS or SSH/SCP or whatever directly from anywhere in the world.
If not then your PC will need a public IP address that the Pi can connect back to instead. In this case a VPN like wiregard installed on your PC may be appropriate.
If neither end can get a public IP address then it is impossible for them to contact each other directly and you will need a server in the cloud that they can use as an intermediary. A VPN service provider for example. Or you could run your own server on Google cloud, Amazon, Azure etc.
Alternatively you can use the services of someone like Dataplicity
https://www.dataplicity.com or Balana
https://www.balena.io/ to get your Pi onto the net. Both of those have worked will for me in the past and have free offerings.
Memory in C++ is a leaky abstraction .