Re: for each member of a sturcture/class ?
  Home FAQ Contact Sign in
comp.std.c++ only
 
Advanced search
POPULAR GROUPS

more...

comp.std.c++ Profile…
 Up
Re: for each member of a sturcture/class ?         


Author: Roman.Perepelitsa
Date: Dec 18, 2007 08:58

On 17 Dec, 19:19, tazmas...@rocketmail.com ("Jim Langston") wrote:
> One thing that would help me a lot in code would be something that allowed
> me to iterate through the members of a class or structure. Consider
> serialization.
>
> To serialize a class or structure I need to serialze each type (not hard)
> then in the class serialize each variable. For a simple structure, such as
> holding integers and std::strings, if there was some way to iterate through
> the variables it would be simple something like in pseudo code:
>
> std::ostream& operator<<( std::ostream& os)
> {
> for_each_member( os << member );
>
> }
>
> There is also a case where I want to tie a structure/class into a database
> and need to go through each variable and call a function to tie it in, a
> simple thing if there was a way to call something for each variable.
> ...
Show full article (2.46Kb)
no comments