473,508 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ERROR.......non-lvalue in increment

1 New Member
Program won't compile..What is this error..Please explain?


#include<iostream>
using namespace std;
main()
{
int num1=0,num2=10,result;
num1++;
result=++(num1+num2); //error:non-lvalue in increment
cout<<num1<<" "<<num2<<" " <<result;
system("pause");
return 0;

}
Feb 3 '15 #1
1 2542
weaknessforcats
9,208 Recognized Expert Moderator Expert
(num1+num2) written this way is an expression which is only true or false. A binary value cannot be incremented.

Just use a variable instead:

Expand|Select|Wrap|Line Numbers
  1. int sum;
  2.     sum = num1+num2;
  3.     ++sum;
Feb 3 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
7310
by: Christopher | last post by:
I have the following errors, can someone explain how I accomplish the pointer assignment here? Error Message : CQueue.cpp: In member function `void cs3358Fall2003::circular_queue::push(const...
2
12701
by: Tom | last post by:
I am trying to store information into a table that has an auto increment field. There is currently no data in the table. Using the code below I cannot insert data into the table. I get an error...
14
1766
by: pai | last post by:
hi.. I have a simple doubt about increment operators.. Can any one tell me what is really happening.. Eg: int i=0,ans; ( ans = ++i ++i // This
13
2521
by: albert_reade | last post by:
Could someone help me figure out why this error keeps occuring thanks for the help. error: cc FordFulkerson.c FordFulkerson.c:117:2: warning: no newline at end of file Code: #include...
0
2035
by: erik.erikson | last post by:
I am getting a compiler error that I can't well explain or even understand the origin of (though I boiled it down close...). Below is a bare-bones example. What I am doing is defining the...
26
6246
by: drako | last post by:
Hi, I'm a bit stumped as I am getting a "Notice: Array to String Conversion" error when trying to do something that on the surface should be a very simple task - create an array, and write a set...
2
6603
by: dobbouk | last post by:
I'm getting these 2 errors and haven't got a clue whats causing them please java 43: illegal start of type for (i=0;i< Number_of_squares; i++) java 215 identifier expected } ...
13
3759
Topbidder
by: Topbidder | last post by:
I have this error on the code Parse error: syntax error, unexpected '"' in /home/topbidd/public_html/bid2/bid_classic.php on line 159 now i thought the error was this It seems that the...
4
2082
by: thiagorisan | last post by:
Hi Guys.. I Heave the problem with my script of BPPennyMultiBid. This is Error: Parse error: syntax error, unexpected '"' in /home/thi8isju/public_html/bid_classic.php on line 159 This is...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.