• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

Why prefix is faster than postfix

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prefix operation is faster and better than to postfix operation.
Now let us see how both postfix and prefix work.

// postfix
iterator operator++(int)
iterator _Tmp = *this;
return (_Tmp);

// prefix
iterator& operator++()
_Ptr = _Acc::_Next(_Ptr);
return (*this);
note: one integer dummy variable is used in postfix operation in order to distinguish weather it is a postfix operation or prefix operation. This dummy variable is never used.
(refer prefix / postfix overloading).

hope it would be helpful to all of you.
Any suggestions are appreciated.

No thanks. We have all the government we need. This tiny ad would like you to leave now:
Two software engineers solve most of the world's problems in one K&R sized book
    Bookmark Topic Watch Topic
  • New Topic