Thread: Fixing the Indentation draft

  1. #46
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    Quote Originally Posted by citizen View Post
    >> Oh and n++ is not the same as ++n

    We know. But the behavior difference is basically the only reason to prefer one or the other, especially considering looping. Nevertheless, people will look at n++ in a for loop and be like "damn you're not optimizing and writing code at the same time! Shock and horror!"
    Just for the sake of keeping a flamewar going, it can be a good habit to use ++n within loops, not for performance reasons, but because of iterators. Although all of the standard iterators will be fine with n++, some custom written iterators do not implement the copy constructor, and thus ++n will work, while n++ will not compile. Thus, ++n everywhere enforces consistency.
    Programming Your Mom. http://www.dandongs.com/

  2. #47
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I find the point moot. Since ++n and n++ does different things, there are times when you will avoid from using the same syntax. It's also a matter of opinion, because a few construction/destruction/copying of objects isn't going to hurt performance very much unless done very much.
    So I usually say go with whatever you fancy and don't worry about it.
    And btw, things lacking a copy constructors such as iterators are broken (things which should allow to be copied).

    Now, back to the indentation or coding style draft.
    Last edited by Elysia; 02-23-2008 at 11:18 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #48
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Although all of the standard iterators will be fine with n++, some custom written iterators do not implement the copy constructor, and thus ++n will work, while n++ will not compile.
    I think those custom iterators need to be fixed.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-23-2009, 06:20 PM
  2. Indentation in Code::Blocks
    By PING in forum Tech Board
    Replies: 8
    Last Post: 03-26-2008, 03:33 PM
  3. setting indentation in dev-c++
    By richdb in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 06-12-2006, 08:03 PM
  4. Fixing my (Stupid) IE Menubar
    By civix in forum Tech Board
    Replies: 2
    Last Post: 01-04-2004, 02:22 AM
  5. Fixing Laptops
    By zdude in forum Tech Board
    Replies: 5
    Last Post: 06-16-2003, 01:56 AM