Which is faster post increment or pre increment ? and in
which cases should u use either - to increase speed?
Answer Posted / me
In normal cases where we use x++ or ++x for integer
variables in loops etc, both behave the same.
However, when we have classes that overload the ++
operator, it's faster to use the ++x rather than x++.
This is because when we do x++, a temporary object is
created to point to the original value, then the value is
incremented, and the pointer is updated and returned.
in case of ++x, just the value is incremented and pointer
to itself is returned. therefore ++x is faster in this case.
Is This Answer Correct ? | 31 Yes | 1 No |
Post New Answer View All Answers
Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box
What is overloading in oops?
What is an example of genetic polymorphism?
What is object in oop with example?
What is polymorphism explain its types?
What is interface in oop?
What are different oops concepts?
Can destructor be overloaded?
What does it mean when someone says I oop?
What is constructor in oop?
What is the use of oops?
Plese get me a perfect C++ program for railway/airway reservation with all details.
write a program to find 2 power of a 5digit number with out using big int and exponent ?
What are the benefits of polymorphism?
What are the types of abstraction?