Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7648537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:44:29+00:00 2026-05-31T10:44:29+00:00

In Mr Kenny Kerr’s this column , he defined a struct and a typedef

  • 0

In Mr Kenny Kerr’s this column, he defined a struct and a typedef like this:

struct boolean_struct { int member; };
typedef int boolean_struct::* boolean_type;

Then what is the meaning of this typedef?

Another question is concerning the following code:

operator boolean_type() const throw()
{
    return Traits::invalid() != m_value ? &boolean_struct::member : nullptr;
}

What is the meaning of “&boolean_struct::member” ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:44:30+00:00Added an answer on May 31, 2026 at 10:44 am

    In Mr Kenny Kerr’s this column, he defined a struct and a typedef like
    this:

    struct boolean_struct { int member; };    
    typedef int boolean_struct::* boolean_type;    
    

    Then what is the meaning of this typedef?

    The typedef creates a type called boolean_type which is equivalent to a pointer to an int member inside a boolean_struct object.

    It’s not the same thing to a pointer to an int. The difference is that an object of boolean_type requires a boolean_struct object in order to dereference it. A normal pointer to an int does not. The best way to see how this is different is via some code examples.

    Consider only normal pointers to ints:

    struct boolean_struct { int member; }; 
    
    int main()
    {
        // Two boolean_struct objects called bs1 and bs2 respectively:
        boolean_struct bs1;
        boolean_struct bs2;
        // Initialize each to have a unique value for member:
        bs1.member = 7;
        bs2.member = 14;
    
        // Obtaining a pointer to an int, which happens to be inside a boolean_struct:
        int* pi1 = &(bs1.member);
        // I can dereference it simply like this:
        int value1 = *pi1;
        // value1 now has value 7.
    
        // Obtaining another pointer to an int, which happens to be inside
        // another boolean_struct:
        int* pi2 = &(bs2.member);
        // Again, I can dereference it simply like this:
        int value2 = *pi2; 
        // value2 now has value 14.
    
        return 0;
    }
    

    Now consider if we used pointers to int members inside a boolean_struct:

    struct boolean_struct { int member; }; 
    typedef int boolean_struct::* boolean_type;   
    
    int main()
    {
    
        // Two boolean_struct objects called bs1 and bs2 respectively: 
        boolean_struct bs1; 
        boolean_struct bs2; 
        // Initialize each to have a unique value for member: 
        bs1.member = 7; 
        bs2.member = 14; 
    
        // Obtaining a pointer to an int member inside a boolean_struct
        boolean_type pibs = &boolean_struct::member;
    
        // Note that in order to dereference it I need a boolean_struct object (bs1):
        int value3 = bs1.*pibs;
        // value3 now has value 7.
    
        // I can use the same pibs variable to get the value of member from a
        // different boolean_struct (bs2):
        int value4 = bs2.*pibs;
        // value4 now has value 14.
    
        return 0;
    } 
    

    As you can see, the syntax and their behavior are different.

    Another question is concerning the following code:

    operator boolean_type() const throw()
    {    
        return Traits::invalid() != m_value ? &boolean_struct::member : nullptr;  
    }
    

    What is the meaning of “&boolean_struct::member” ?

    This returns the address of the member variable inside a boolean_struct. See above code example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

int value = 5; // this type of assignment is called an explicit assignment
EDIT: Thanks Kenny and everyone else who answered similarly. It really was a DOH
I have the following css applied to the corresponding html snippet. I would like
I've never seen this happen before and I can't figure out what is causing
Hi im having trouble with this sql. Basically it displays statuses that my friends
I'd like to know if anybody can provide a step-by-step how to on how
I've got a table with a BLOB column. What I want to do is
This is pretty much a duplicate of this unanswered question , but hopefully someone
Why I'm getting this error when deleting a row in DataGridView control? How can
For those that have been helping me along the way with this twitter-clone, thank

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.