-
August 12th, 2010, 03:21 PM
#1
What is this kind of syntax called?
Hi,
I am relatively new to C++. I found this piece of code in a project I am working on. Somebody else wrote it. I have never seen this kind of syntax before and I am curious to know more about it:
class A { bool flag; };
class B { A a1, a2, a3; };
/* this is the syntax i haven't seen before */
A B::* arrayname[3] = {&B::a1, &B::a2, &B::a3};
B b;
...
/* and this is how to use it */
if ((b.*arrayname[0]).flag) ...
Thank you.
-
August 12th, 2010, 03:31 PM
#2
Re: What is this kind of syntax called?
They're basically pointers which count from the start of a given object rather than globally, effectively allowing you to "choose" a particular field of an object without having to tie the pointer to that *particular* object.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|