error C2440: 'reinterpret_cast' : cannot convert from 'fileSystem' to 'char *'
1> Conversion requires a constructor or user-defined-conversion operator, which can't be used by const_cast or reinterpret_cast
If you can tell how to make this thing possible then that would really be a useful thing for me.
Yeah. You don't want to dereference the pointer when you cast it. You only need to dereference it on the second argument.
You know that the file created is going to be useless, right? I'm assuming you're doing this as some sort of exercise to create a random file of a certain size.
Hmm impressive; but I think I will be able to load this file into an object once I've written my object, so this file won't be useless. Am I right? Will I be able to load it into an object of sameType?
You absolutely must not do this. It will not work as you expect.
Your 'filesystem' class contains a pointer and therefore is not a POD type, so a straight dump of its memory to a file will not preserve all the information you are trying to preserve. When you load the file later, you will have a stray pointer that points to random garbage in memory.
@Disch, O no it is problematic for me if it's true (I'll check it when I fill my object with data). Is there a solution to write an object of say 10MB and then read it back in another object of same type?
The size of the object does not matter, as long as the object contains only POD types. Your 'filesystem' class contains a pointer, which is not a POD type.
You can't just write a pointer to a file. You need to follow the pointer and write the data it points to. In your case, since it points to a node which I'm assuming is part of a tree... this is nontrivial. You'll have to walk through the tree and save the data (but not the pointer) from each node.
This will take planning. I recommend you map out the desired spec for your file format and save each field individually rather than trying to write objects in bulk.