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
Is abstract thinking intelligence?
What is the types of inheritance?
What is the difference between a mixin and inheritance?
Whats is abstraction in oops?
What is the main purpose of inheritance law?
• What are the desirable attributes for memory managment?
What is inheritance write a program to show use of inheritance?
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
Plese get me a perfect C++ program for railway/airway reservation with all details.
What is the point of polymorphism?
Why multiple inheritance is not possible?
What is variable example?
What type of loop is a for loop?
write knight tour problem which is present in datastructure