46
Network / Re: Sending Custom Class by packet (to different program)
« on: December 07, 2021, 08:09:21 pm »
I don't really get it.
You overload >> and << for your Character class.
Inside these 2 functions is where you want to put/retrieve the data to/from the packet.
Then you simply send your Character john with
You don't extract every data of your character individually (well you can, but what's the point) you directly extract a character and the overloaded >> operator function takes care of extracting the individual data.
You overload >> and << for your Character class.
Inside these 2 functions is where you want to put/retrieve the data to/from the packet.
Then you simply send your Character john with
packet << john
and retrieve it withCharacter john; // creates john
packet >> john; // fills john with data from the packet
packet >> john; // fills john with data from the packet
You don't extract every data of your character individually (well you can, but what's the point) you directly extract a character and the overloaded >> operator function takes care of extracting the individual data.