You should use an actual ROS message instead of a custom class for data that you'd like to publish/subscribe to. See http://wiki.ros.org/ROS/Tutorials/CreatingMsgAndSrv for how to create a new message that you can then use when publishing data. Using a ROS message also means that existing ROS tools such as rostopic
and entire language bindings such as rospy
for Python or rosjava
for Java will be able to easily interoperate with your C++ node.
For this particular case, you can simply use the standard ROS message for a 3D point, geometry_msgs/Point. You can find a fairly comprehensive list of the standardized messages in the common_msgs documentation. Using a standardized message has a number of benefits over creating your own message with essentially the same content - the biggest is that there are many tools or other pieces of software in the ROS ecosystem that you may want to take advantage of later, which will be a fairly painless process if you are already using standarized message types.
If you really have a need to use your custom Position class (without simply converting it to a ROS message), you can look at the roscpp serialization documentation. I would strongly suggest against serializing your custom class instead of using either an actual ROS message that you create or a standardized message.