Nolan Martin wrote:[color=blue]
>
>
> If only it were that simple...
> I am trying to streamline the process of serialization in my program by
> storing the location of constructor helper functions (function that returns
> "new someclass"), so that all you need to do to make a class serializeable
> is give it a helper function and implement a serialize function. the
> serialize function will write a "pointer" to the inheritied helper function
> then the remaining data. This allows me to implement new classes without
> having too much overhead code preparing the lookup table and dramatically
> simplifys things.[/color]
Bad idea.
At the moment you do some modifications to your program (and you will do this)
all addresses change. Go the way Victor has suggested.
[snip]
[color=blue]
>
> the only thing this relys on is that the functions address is allways the
> same and that it uses the vtable to look up the serialize function during
> deserialization...I wonder how the functions location is stored for a normal
> function call, does the compiler not simply replace the name with the
> functions address at compile time making the address constant?[/color]
Sure it does. But at the moment you insert eg. a variable somewhere or
so some bug fixes all addresses might change. This is exactly why
programming in assembler is much more productive then hacking opcodes
in hex. The translating program keeps track of where things are located
in memory. You pay for this convinience by not interfering or depending on
a particular memory layout.
--
Karl Heinz Buchegger
kbuchegg@gascad.at