user3498783
user3498783

Reputation: 213

typedef type * type::* , what is it?

I have the following code:

  struct myType { myType * ptr; };
  typedef myType * myType ::* other_type;

What is the second line typedef'ining? Is that a member function that returns a myType pointer or something else?

Upvotes: 5

Views: 244

Answers (1)

John Zwinck
John Zwinck

Reputation: 249502

That defines other_type as a pointer to a member of myType where said member is itself a pointer to myType. For example, you could use it this way:

other_type x = &myType::ptr;
myType mine;
mine.*x = &mine;

Why you would do that, I can't say.

Upvotes: 6

Related Questions