Search:

Type: Posts; User: anon

Page 1 of 20 1 2 3 4

Search: Search took 0.04 seconds.

  1. Replies
    16
    Views
    8,525

    There are more problems. Converting the result...

    There are more problems.

    Converting the result of pow, which is a floating point value, to integer may cause rounding errors, e.g 10003 may well come out as 999,999,999. You would be much better...
  2. Replies
    5
    Views
    3,791

    Is it a warning or an error? What is the compiler...

    Is it a warning or an error? What is the compiler (Code::Blocks is not a compiler) and the flags?
    Your code should not produce an error and I don't see any reason to warn about synthesized default...
  3. Replies
    22
    Views
    9,963

    This way, the code won't suddenly blow up in a...

    This way, the code won't suddenly blow up in a release build should a NULL pointer unexpectedly arrive.


    Interesting. But the code won't do the right thing anyway. Doesn't this just mask the...
  4. Replies
    11
    Views
    4,519

    I believe this has already been explained. ...

    I believe this has already been explained.



    TimeCalc time5 = "14:34";


    means almost the same as
  5. Replies
    11
    Views
    4,519

    No, it just allows binding temporaries to...

    No, it just allows binding temporaries to non-const references. (And there might not be a way to turn off this compiler extension?)
  6. But if you insist on finding the divisors, you...

    But if you insist on finding the divisors, you can add them to a std::vector, which is a dynamically growing array. The reason is that you don't know how many divisors there's going to be (you'd know...
  7. I'm not sure this is a matter of optimization,...

    I'm not sure this is a matter of optimization, but rather using a rather unsuitable algorithm to begin with. 300 billion trial divisions is way too much work, even if you sort out the memory problems...
  8. Euler problem 3...

    Euler problem 3 is about prime factors, otherwise finding the largest divisor would be a bit too trivial. The problem might look intimidating, but I suppose it can be solved with simple trial...
  9. Compilers may be smart enough to merge code for...

    Compilers may be smart enough to merge code for different tsize.


    No way.


    The functionality might be a bit different. E.g in the dynamic case you need to be able to set the size, in the...
  10. Replies
    3
    Views
    1,627

    If you only want to use the predicate in the...

    If you only want to use the predicate in the constructor, you can make the constructor a template.



    template<typename T>
    class Myfoo
    {
    public:
    template <class Pred>
    Myfoo(Pred p);
  11. Replies
    6
    Views
    6,392

    When you are dealing with larger prime numbers,...

    When you are dealing with larger prime numbers, you might need the Sieve of Eratosthenes. At ideone.com I can get the answer within 0.01 seconds, which I doubt your program gets anywhere close to.
  12. Replies
    4
    Views
    1,135

    For one thing, none of your calculations involve...

    For one thing, none of your calculations involve a. You rather seem to be adding 2^1 + 2^2 + 3^1 + 3^2 + ... + 9^8 + 9^9 (except that you keep accumulating things to the same p).
  13. Yes, argument and return types may be incomplete...

    Yes, argument and return types may be incomplete in function declarations. For example, within a class definition the class itself is incomplete (but it is complete in methods defined inline):


    ...
  14. pcl::PointCloud ::Ptr is a...

    pcl::PointCloud<pcl::PointXYZRGB>::Ptr is a typedef for boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> >. It already is a smart pointer, which means you needn't and must not try to delete it...
  15. Replies
    12
    Views
    3,655

    You return locals by value, and if there is a...

    You return locals by value, and if there is a move constructor, this will be invoked to move the result to the caller.
  16. Replies
    6
    Views
    4,569

    Those are not the same: char str[] =...

    Those are not the same:



    char str[] = "Example string"; //the type of str is char[15]
    char* str = "Example string"; //the type of str is char*


    Furthermore, in the second case it's a...
  17. Thread: Fibonacci

    by anon
    Replies
    8
    Views
    2,574

    A start might also be to write, say, a program...

    A start might also be to write, say, a program that outputs all odd numbers up to users input.
  18. Replies
    3
    Views
    1,966

    You are trying to use a as a loop counter, at the...

    You are trying to use a as a loop counter, at the same time setting it to 0 inside the loop.
  19. Replies
    48
    Views
    10,572

    Perhaps a Officetype of guy? May-be it is my...

    Perhaps a Officetype of guy?

    May-be it is my bad understanding of humour, but the questions and answers are just a joke (the "correct" answers are seemingly logical, yet make no sense given the...
  20. Thread: infinite loop?

    by anon
    Replies
    4
    Views
    1,294

    If cin expects a number but is given something...

    If cin expects a number but is given something else, it switches into an error state. Any following input statements will fail without managing to consume any of the input, unless you correct the...
  21. Replies
    48
    Views
    10,572

    How do you know there's an elephant in the...

    How do you know there's an elephant in the fridge? - In C++ there's no standard way to know that, unless you keep track of elephants entering and exiting the fridge manually.
  22. Replies
    48
    Views
    10,572

    I fail to see how this answers the how-question....

    I fail to see how this answers the how-question. Perhaps the question should be reworded to "what you have to do to end up with an elephant inside a refigerator?"

    -----------

    Perhaps a better...
  23. Replies
    3
    Views
    1,308

    No, you can not use the struct keyword there. ...

    No, you can not use the struct keyword there.

    However, the class keyword doesn't mean that T can only be a class. It can be any type. The synonym for class is typename in this context.
  24. Replies
    9
    Views
    2,500

    for (i=1; i

    for (i=1; i<=n; i*=2)

    Is this really a loop of order n, and not perhaps of log(n)?
  25. Replies
    15
    Views
    4,752

    It seems Comeau online doesn't even have...

    It seems Comeau online doesn't even have std::shared_ptr in the standard library.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4