pointer members member?

G

Georg D.

hi,

with

struct C
{
string f1;
};

class A
{
C data;
};

what is the best way to pass member pointer to f1
relative to class A, sth. like a::data.f1?

---- backgroud:
i'd like to compose classes in following way:

--- generic part ---

// carry some data
class field
{ ...
};

// keep information on (contained) fields
class record_definition
{ ...
};

// and perform common actions
class record
{
shared_ptr<record_definition> recdef;
public:
record(shared_ptr<record_definition> _recdef) : recdef(_recdef) ...
...
};


---- user's part ----

// here is the data struct
struct data_t
{
field f1;
field f2;
...
};


// here, the data_t is enhanced with
// functionality from record
// my_record provides record definition
// so class record has acces to the fields
class my_record : public record
{
protected: // but could be public as well
data_t data;
};

--------

my_record would pass pointers to members member fields
f1, f2 etc.

TIA,
georg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top