Search:

Type: Posts; User: robatino

Page 1 of 20 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    28
    Views
    2,548

    I don't think anyone who indents their code...

    I don't think anyone who indents their code properly should care about whether the braces can be found easily in unindented code. And if the code is indented properly, in any style, each scope can...
  2. Replies
    28
    Views
    2,548

    Objectively, it's no less readable than K&R or...

    Objectively, it's no less readable than K&R or Allman. In all three, to the human reader, scope is determined by a statement's horizontal offset. If the braces were invisible, the code could be...
  3. Replies
    28
    Views
    2,548

    See http://en.wikipedia.org/wiki/Indent_style...

    See

    http://en.wikipedia.org/wiki/Indent_style

    The first code snippet is an example of K&R, the second of Allman. Allman has the advantage of treating the opening and closing braces...
  4. Replies
    3
    Views
    2,091

    The sum from n == 1 to N of 1/n is going to be...

    The sum from n == 1 to N of 1/n is going to be something on the order of ln(N) (since the integral of 1/x is ln(x)). By drawing diagrams it's pretty easy to put both lower and upper bounds on the...
  5. Replies
    14
    Views
    2,185

    K&R2 also casts the return value of malloc()...

    K&R2 also casts the return value of malloc() which is also generally considered a bad idea.

    Casting malloc
  6. Replies
    6
    Views
    916

    > It should also be mentioned that in this case...

    > It should also be mentioned that in this case "new" means "1989" (if not farther back).

    K&R2 uses the ANSI-style declarations, and that came out in 1988.
  7. Replies
    26
    Views
    2,747

    I'm confused about the terminology - Stroustrup...

    I'm confused about the terminology - Stroustrup in TC++PL (section 10.4.2, page 244) says "Built-in types also have default constructors (Section 6.2.8)." So, is int() (for example), which does zero...
  8. Replies
    21
    Views
    1,919

    George2's example is exactly what I have in my...

    George2's example is exactly what I have in my copy of TC++PL (9th printing, January, 1999).

    Edit: 3rd edition
  9. Replies
    39
    Views
    3,897

    It's a US IBM keyboard. The "" and "|"...

    It's a US IBM keyboard. The "\" and "|" characters are on the same key, just under the backspace key, which is not the easiest place to reach.

    Edit: It looks like this:
    ...
  10. Replies
    39
    Views
    3,897

    That's weird, every keyboard I've seen has "/"...

    That's weird, every keyboard I've seen has "/" and "?" on the same key, including the Dell machine I'm using now, which originally had XP only installed, and came with this keyboard.
  11. Replies
    39
    Views
    3,897

    > And I really, really hate "/". It looks...

    > And I really, really hate "/". It looks disgusting IMHO. So I always use "\".

    Why is the DOS path character "\"?

    Basically, in DOS, "/" was already being used for something else, so they...
  12. Replies
    33
    Views
    4,207

    No. In my example, since all you know is that...

    No. In my example, since all you know is that the size is usually somewhere on the order of N (meaning it could easily be twice N, or half N, for example), then it doesn't make any sense to...
  13. Replies
    33
    Views
    4,207

    Well, suppose you have a vector v which grows to...

    Well, suppose you have a vector v which grows to some size which you don't know exactly in advance, but you only know that the size has an theoretical upper bound of N*N, say, where N is some...
  14. Replies
    6
    Views
    858

    It's probably because brevity is more important...

    It's probably because brevity is more important in a paper book than in a source file - even Stroustrup's book leaves out std:: in its code snippets. (BTW, it's spelled "propane", without an i, and...
  15. Replies
    20
    Views
    11,699

    Yes, good point. In fact, even if it was slower...

    Yes, good point. In fact, even if it was slower in terms of CPU, the extra cache efficiency for a large array might make up for it, resulting in greater overall speed (if the bottleneck was memory...
  16. Replies
    33
    Views
    4,207

    Although if the exact size needed isn't known in...

    Although if the exact size needed isn't known in advance, and one only has an upper bound which is much larger than the "average", then asking the OS to allocate that much could be counterproductive,...
  17. Replies
    20
    Views
    11,699

    I'm not a hardware person, but since the standard...

    I'm not a hardware person, but since the standard allows float and double to be the same size, there wouldn't be any reason to allow a smaller floating-point type if it was also slower, so I would...
  18. If 65535 isn't big enough, the Standard...

    If 65535 isn't big enough, the Standard guarantees that unsigned long goes up to at least 2^32 - 1 == 4294967295.
  19. Replies
    33
    Views
    4,207

    Found this by searching for "deque capacity:" ...

    Found this by searching for "deque capacity:"

    GotW #54: Using Vector and Deque
  20. Replies
    12
    Views
    1,089

    Assuming v is nonempty, of course - otherwise...

    Assuming v is nonempty, of course - otherwise v[0], and hence &v[0], invokes undefined behavior (as CornedBee pointed out in a previous thread). On the other hand, v.begin() is a valid iterator...
  21. Replies
    31
    Views
    2,319

    The following is a snippet from the GCC man page...

    The following is a snippet from the GCC man page (-W being the same as -Wextra):
  22. cpjust: Yes, that works! Thanks. Sebastiani: ...

    cpjust: Yes, that works! Thanks. Sebastiani: Yes, I should have seen that, though that change by itself didn't fix it. However, also changing A* to A<T>* in the class declaration as in cpjust's...
  23. syntax for a tricky class template static member definition

    I have a class template with an iterator as a static member. Below is a simplified version of the code. I'm having trouble with the proper syntax for the definition (line 9). Can anyone help?

    ...
  24. Replies
    11
    Views
    1,625

    When using vectors, reserve() can be used if you...

    When using vectors, reserve() can be used if you know in advance the exact maximum memory capacity needed, and the "swap trick" can be used to trim the capacity to the actual size of the vector, if...
  25. My understanding was that in the context of...

    My understanding was that in the context of C/C++, a byte by definition was whatever the size of a char is (so one can say that sizeof() returns the size in bytes, with sizeof(char) always being 1,...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4