Haha what!! I'm in an intermediate c++ class in uni and one of my assignments is to write a similar object into a binary file and we didnt learn google protobuf or apache avro, is there really simple solution to this problem?
Usually this means classes that have pointer data members. In your case you nave a NodeType* and a couple of std::strings.
So then how would you write an object to a binary file?
You'll need to write out each individual member. For members like std::string you'll probably need to first write the size of the string then write the string using the c_str() member function. You'll have to decide what you want to do with that NodeType pointer.
If you're going the object route, it would be better to add a function to the class such that it writes itself to file. Nice and neat and self-contained.
Either approach could be made to work but writing only the attributes into a standardized format in discrete values is usually neater. It also makes for easier debugging if the raw data is in a format that you can read.