473,289 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

postfix and prefix

How can we implement operator ++ as postfix in prefix?

thanks
Oct 6 '08 #1
2 2421
On Oct 6, 2:01*pm, puzzlecracker <ironsel2...@gmail.comwrote:
How can we implement operator ++ as postfix in prefix?

thanks
Not really sure what you are asking, but the ++ operator can be
applied in front of a variable or behind it. If in front, the value is
incremented before the value is "looked at". If after, the value isn't
incremented until after it is "looked at".
Oct 6 '08 #2
puzzlecracker kirjoitti:
How can we implement operator ++ as postfix in prefix?

thanks
In C

int a=10;
printf("%d\n", ++a);

prints 11 and

int a=10;
printf("%d\n",a++);

prints 10

(and on both cases, a is 11 after the code).

The first ++ is called prefix and the second postfix.

On C++ if you like to add ++ to your own classes, you have to implement
separate operators for postfix and prefix ++ operators. However, this
article : http://devhawk.net/2003/07/10/Operat...ding+In+C.aspx
claims that for C# you have to implement only one operator, the compiler
handles the difference.

--
Arto Viitanen
Oct 7 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Henry Jordon | last post by:
ok I have my problem entering in an expression in infix notation and it outputs the postfix notation. I now need to evaluate the postfix notation. I have some code written and there are comments as...
6
by: Sergey | last post by:
Hello! Could anybody be kind enough to explain this concept? Why C++ make two ops for prefix and postfix ++ operator? As I guess, it is possible to implement both cases via sole prefix...
2
by: Christian Christmann | last post by:
Hi, is there a difference in terms of efficiency when using a prefix "++x;" instead of a postfix "x++;"? Thanks Chris
8
by: lovecreatesbeauty | last post by:
Hello experts, Why can this difference between prefix increment/decrement and postfix increment/decrement reside in built-in operators for built-in data types? Thanks. // test.cpp // //...
98
by: jrefactors | last post by:
I heard people saying prefix increment is faster than postfix incerement, but I don't know what's the difference. They both are i = i+1. i++ ++i Please advise. thanks!!
2
by: shan | last post by:
Hi to everybody, I am begginer in C programming language. My simple doubt is the difference between postfix & prefix unary operator plus. (i.e) i++ and ++i . plz give me an example program...
30
by: Xah Lee | last post by:
The Concepts and Confusions of Prefix, Infix, Postfix and Fully Functional Notations Xah Lee, 2006-03-15 In LISP languages, they use a notation like “(+ 1 2)” to mean “1+2”....
8
by: subramanian100in | last post by:
Consider int i = 10; Why do we say that ++i yields an Lvalue and i++ yields an Rvalue ? I thought both these expressions yield only values. I am unable to understand the difference
2
by: swapnaoe | last post by:
Hi, In http://elearning.embnet.org/file.php/43/ctutorial/Postfix-and-prefix----and---.html I read about postfix and prefix unary operators. It said " If the increment or decrement operator is...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.