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

  • SEARCH
  • Home
  • 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 8290535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:50:32+00:00 2026-06-08T12:50:32+00:00

void InsertA(SET *A,int elem) { if( isMember(*A,elem) == false) { *A = *A ||

  • 0
void InsertA(SET *A,int elem)
{
    if( isMember(*A,elem) == false)
    {
    *A = *A || 1<<elem;; /*it says its in this row*/
    }
}

/*Error: Lvalue required in Function InsertA
any thoughts on this guys? noob here

*/

  • 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-06-08T12:50:33+00:00Added an answer on June 8, 2026 at 12:50 pm

    In this statement :

    *A = *A || 1<<elem;; /*it says its in this row*/
    

    We have these operators *,=,||,<<

    Now look at the precedence table at

    Precedence    Operator   operation                  associativity 
                   --------   ---------                 ----------------
    3                  *       Indirection (dereference)       R to L
    7                  <<       Bitwise left shift             L to R
    14                 ||       Logical OR                     L to R
    16                 =       Direct assignment               R to L
    

    So lets see what happens:

    1) Indirection will be performed first. There are two of them. They associate Right to Left. That means Right one will be performed first. Its important to understand that there are two dereferencing operator here which will be considered differently later when encountering the = operator.

    2) A bit wise left shift will performed on 1.
    3) A logical OR will be performed with *A and the result of bitwise shift. it may evaluate zero or non zero.
    4) This zero/nonzero value will be assigned to *A. Here *A can be treated as lvalue in a context of = operator. If you leave this consideration it will lead to ambiguity. Because we often think of dereferencing operation like *A as an rvalue or an value to be used. Actually its a valid lvalue which will be converted implicitly to a rvalue (This is when a value which is stored at address pointed by A is returned). Otherwise *A is simply a container in memory which is open to values.

    So the thing is your expression is undefined and does not make any sense why you are putting a logical value into *A. It will make more sense if you use binary or instead of logical.

    Lets do that:

    We have a new entry in our precedence table

    Precedence OP   OPeration        Associativity 
    12         |    Bitwise OR          L to R
    

    Only change will occur in step 3 when a bitwise OR will be performed.

    Lets have an example

    lets say elem = 3.
    A is pointing to the array {1,2,3,3,4}

    1) ‘*A’s will be performed. It will just calculate the “Offsets” needed to do load or store instructions of the processor.

    2)we will get a constant bit pattern : 1 << 3 = 1000
    3)now for | we need rvalues as both operands. So now a load instruction will be performed to fetch the value stored in the memory. Say its 2. So we will get 0010 | 1000 = 1010
    4)A store instruction will be performed to put this bit pattern into the memory so the array will look like {1,A,3,3,4}

    Explanation for too much verbosity: I think this can help if future users who will try to find how to dissect a complicated expression by language rules.

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

Sidebar

Related Questions

#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }; void insert( struct
In my void union function I am unsure how to insert the data from
I have a method to insert data into server like this: public void doInsert(){
- (void)TargetHit:(int)target{ void (^threadBlock)(void) = ^{ NSLog(@respond to selector %d, [self respondsToSelector:@selector(changeImageOfTarget:)]); [[NSOperationQueue mainQueue]
I have a class named Entry declared like this: class Entry{ string Id {get;set;}
I want to use a DLL in my program which has a function void
i have one interface like, public interface Details { int Id { get; set;
Let's say I have a class: class NumberCollection { public: typedef std::set<int> SetType; typedef
I recently migrated to new version of protobuf-net, and i started getting this error
We have 2 tables: Table Authority: public class Authority { public int ID {get;set;}

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.