CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums


Type: Posts; User: D_Drmmr

Page 1 of 80 1 2 3 4

Search: Search took 0.03 seconds.

  1. Replies

    Re: Issue in nested stl maps

    Please format you code to make it readable.

    APN2PolicyRules cApn2PolicyRulesInfo = iTer->second;

    This creates a copy. The copy is not in the map, so anything you do with the copy will not...
  2. Re: How to design unordered_map's hash function for this case and another one?

    I don't see the relation between your new question and the OP. Please start a new thread.
  3. Re: Using #define with colons (e.g. with a namespace)

    You could define a global constant for the value.

    namespace Something {
    #ifdef _MSC_VER
    const auto Binary = std::ios::binary;
    const auto Binary = std::ios::bin;
    } //...
  4. Re: overriding == operator in order to test equality of two pointers

    It's not idiomatic in C++ to use exceptions for control flow. Instead of calling at and catching any exception, call find and compare the returned iterator to actualCosts.end(). That way you can...
  5. Replies

    Re: Accepting a value by reference upon return

    If you need random access, use a vector, not a set.
  6. Re: How to synchronize a worker thread from the main thread?

    I'm really just guessing here, because your terminology is very unusual, but I think you are looking for a triple buffering approach.

    - Keep 3 instances (A, B and C) of the computation result: A...
  7. Replies

    Re: Understanding the Composite Design Pattern

    If you have a tree-like structure in your data, there are several common ways to represent it in your code. Note that a tree is a special type of graph, but this goes for any type of graph.
    In my...
  8. Replies

    Re: Abstraction concept problem?

    Slicing is only a problem is B is designed as a polymorphic base class. If that's the case, you should take either a (const) reference or (smart-)pointer to an abstract base class. You cannot store...
  9. Replies

    Re: Abstraction concept problem?

    From the text I quoted.

    Didn't read that anywhere in your text.

    I agree that the focus on the use of pointers is misleading. It is not pointers that are evil, but they can be a sign of many...
  10. Replies

    Re: Abstraction concept problem?

    I find your suggestion that value semantics are outdated and reference semantics are modern out of touch with modern programming. Reference semantics are much harder to reason about than value...
  11. Replies

    Re: std::vector with negative subscript?

    You can use Boost.MultiArray, which allows setting an 'index base' to change the index of the first element in the array.
  12. Replies

    Re: shared_from_this problem?

    Either use std::shared_ptr, or boost::enable_shared_from_this.
  13. Re: Thread Performance Improvement (A little Advice Please)

    Which compiler (version) are you using? Is this C or C++?
    How do you create the threads?

    If you want to give thread A priority over the other threads, then you should give it a higher priority....
  14. Re: adding rational number using only class functions

    No more with a signed integer than with an unsigned. What's your point?

    Like I said, I tried this for a while and stopped, because I realized I was over-complicating my code.
    With an unsigned...
  15. Re: adding rational number using only class functions

    Obviously. My point is that "the value should never be negative" is not a reason to use an unsigned type. There may still be situations where you need to take a difference or use the value in an...
  16. Re: adding rational number using only class functions

    What would you gain from making the function static? It only requires more typing.
  17. Re: adding rational number using only class functions

    I would strongly advice against mixing signed and unsigned integers. Just take this simple example:

    int numerator = -1;
    unsigned int denominator = 2;
    bool isNegative = (numerator * denominator...
  18. Re: adding rational number using only class functions

    You start by writing all the tests (in this case unit tests) and then implement your class function by function to pass all the tests. This forces you to first think about all the functionality your...
  19. Re: adding rational number using only class functions

    Better to use a bool for the sign (and name it something like isPositive or isNegative), since there can only be two possible states ever.

    Your setnumerator and setdenominator functions violate...
  20. Replies

    Re: Converting JAVA for loop to C++ for loop

    Don't use new [] in C++, there is no need for it. Use std::vector instead.

    And please post the code here, rather than providing some external link.
    What do you mean by "doesn't work"?
  21. Replies

    Re: template class with template members

    That's not really a solution. How will this code be able to create/copy/destroy an instance of X?

    @Tiny Dolls
    Why do you want to get rid of the class template? What do you want to accomplish at a...
  22. Replies

    Re: Handing more than one exception at a time

    Not exactly. It's not throwing the exception during stack unwinding that is the problem. The problem is when the exception thrown during stack unwinding is not caught. If you catch any thrown...
  23. Re: Problem With Sleep() When drawing ananalog clock

    Don't know if threads are covered in the book, but a quick way to make the program update approximately each second is to run the loop in a thread.

    std::atomic<bool> stop(false);...
  24. Replies

    Re: GUI design in C++

    Well, no, because Windows Forms requires .Net and unmanaged C++ doesn't give you that.

    What do you miss?

    If you mean a nice looking GUI application, then yes that's possible in C++.
  25. Re: Problem With Sleep() When drawing analog clock

    Calling sleep pretty much puts your program (well, the thread that calls sleep) into a coma. It doesn't do anything until it wakes from its sleep. One important thing your program won't do while it...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4

Click Here to Expand Forum to Full Width