Noah Roberts wrote:
Consider the following hierarchy:
struct record
{
};
struct test_record : record
{
};
struct an_object
{
test_record r;
};
I want a member pointer variable to r but I want it to be cast as a
record. Is this possible? I tried the following:
static_cast<record an_object::*>(&an_object::r);
No worky.
I still think it's not possible. An instance of type 'an_object' does
not *directly* contain a member of type 'record'. The fact that
'test_record' contains a subobject of type 'record' does not matter.
It's about the same as
struct A { int a; };
struct hasA { A myA; };
int hasA::*p = hasA::myA::a; // or some such syntax.
The use for member pointers is limited and the capabilities are limited
because the language designers weren't concerned with any possible use
of those.
You still haven't answered my question: why do you think you need that?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask