What is this kind of syntax called?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: What is this kind of syntax called?

  1. #1
    Join Date
    Apr 2008
    Posts
    4

    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.

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center