Search:

Type: Posts; User: sigfriedmcwild

Page 1 of 5 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    16
    Views
    20,204

    The real question is: do you have a profile...

    The real question is: do you have a profile telling you this code is a performance bottleneck?

    Just go with the type that fits the logic best (bool or possibly enum in this case). Worry about...
  2. The trick here is that in c/c++ p[n] == n[p] (for...

    The trick here is that in c/c++ p[n] == n[p] (for arrays only of course)

    Basically p[n] returns *(p + n) since arrays are pointers, but + is commutative so it doesn't matter if which way round the...
  3. Replies
    7
    Views
    1,567

    My question was about why the standard was...

    My question was about why the standard was written with those 2 operators, which are very similar (at least for built in types) defined so differently.

    And Java "references" are not references in...
  4. Replies
    7
    Views
    1,567

    operator-> and operator*

    I'm wondering why operator->() returns a raw poiter to an object when operator*() returns a refence

    a->b is supposed to be synctactic sugar for (*a).b and is apparently implemented as:

    ...
  5. Replies
    2
    Views
    1,840

    You could try something like this #pragma...

    You could try something like this



    #pragma once

    template<class T>
    class CSingleton
    {
    private:
  6. Replies
    35
    Views
    5,302

    ??? And yes, for each character type you need...

    ???

    And yes, for each character type you need to determine what kind of character it is and do the shift for that. Or you could Aplly to ceasar cypher to entiere ascii set (or better the entire...
  7. Replies
    35
    Views
    5,302

    Oh well... On a slightly different topic, can...

    Oh well...
    On a slightly different topic, can anyone explain why c++ (and I guess c originally) use such an obtuse implementation of the % operator?
  8. Replies
    35
    Views
    5,302

    Ok, let's try this again, step by step. Any...

    Ok, let's try this again, step by step.

    Any caesar cypher performs a transformation


    cryptchar = (plainchar + shift) % alphabet_size


    the inverse of this transformation is
  9. The problem you described occurs only under...

    The problem you described occurs only under windows when you launch a console application from otuside the console.

    Windows will start a shell, run your program and terminate the shell as soon as...
  10. Well after Daved raised his point I went off and...

    Well after Daved raised his point I went off and did some research.
    Indeed RAII doesn't tell the whole story, the idiom would be more aptly named "resource aquisition is initialisation, release is...
  11. Fair enough. Although RAII does stand for...

    Fair enough.
    Although RAII does stand for resource aquisition is intialisation.

    I always understood the advantage of RAII to be in the object creation stage when the object would come into...
  12. Do you mean using smart pointers? As far as I...

    Do you mean using smart pointers?
    As far as I know RAII (resource aquisition is initialisation) and smart pointers are not the same thing, they just work well together.
  13. I think this was discussed in detail in a guru of...

    I think this was discussed in detail in a guru of the week but I can't remember which.

    If I recall correctly it boiled down to having to catch all the possible exceptions in your constructor,...
  14. Replies
    5
    Views
    1,075

    This bit of code is bad design. Since you are...

    This bit of code is bad design.
    Since you are using this I assume it is a member function. You never need a dynamic cast in a member function, if it is a mamber function of PlaneSound it knows this...
  15. Replies
    35
    Views
    5,302

    the modulus operator will not work in this case...

    the modulus operator will not work in this case since a % b is a negative number if a is negative (if I recall correctly, but if a % b was always in the range [0, b - 1] simple subtraction should...
  16. Thread: Arrays

    by sigfriedmcwild
    Replies
    16
    Views
    1,768

    I was just making sure it was clear to everyone,...

    I was just making sure it was clear to everyone, sorry if I offended you
  17. Thread: Arrays

    by sigfriedmcwild
    Replies
    16
    Views
    1,768

    NULL is a preprocessor macro that expands to 0....

    NULL is a preprocessor macro that expands to 0.
    It is quite possible that a header will declare it or include another header that declared it, but, if I recall correctly, it is not guaranteed by the...
  18. Replies
    4
    Views
    1,524

    My bad. Iterators are invalidated if the vector...

    My bad. Iterators are invalidated if the vector is reallocated however, which could occur when push back is called.
  19. Thread: Arrays

    by sigfriedmcwild
    Replies
    16
    Views
    1,768

    In general use < or

    In general use < or <= for loop conditions.
    If you use != and the number you are checking against (say 5) is skipped for whatever reason (not likely to happen here but fairly easy in more...
  20. Replies
    4
    Views
    1,524

    If I remember correctly any modification to a...

    If I remember correctly any modification to a vector invalidates all iterators.
    My guess is that the segfault comes from calling item++ after update returns since item is no longer valid
  21. Replies
    9
    Views
    12,672

    You could also have a look at boost::lexical_cast

    You could also have a look at boost::lexical_cast
  22. Replies
    21
    Views
    4,711

    You could make a single dimensional array with...

    You could make a single dimensional array with size x*y
    Cell i,j would be accessed by the index i * y + j
  23. Replies
    11
    Views
    6,651

    You could also keep 2 vector that hold the...

    You could also keep 2 vector<int> that hold the cells owner by each player respectively.
    When a player makes a move you take the value of the cell that was just occupied and test it together with...
  24. some of the boost libraries have been included in...

    some of the boost libraries have been included in TR1 (such as smart pointers I think) many others are being considered for inclusion in TR2.
  25. Replies
    14
    Views
    2,170

    It's a struct with operator() defined. Which...

    It's a struct with operator() defined.

    Which means it acts as if it was a function (operator() is called which in this case is a predicate comparing 2 structures)
Results 1 to 25 of 110
Page 1 of 5 1 2 3 4