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

Search:

Type: Posts; User: nuzzle

Page 1 of 80 1 2 3 4

Search: Search took 0.35 seconds.

  1. Replies
    5
    Views
    1,185

    Re: Please help me understand the ouput.

    Well, it looks like you're right. VS2012 actually outputs 2.
  2. Replies
    5
    Views
    1,185

    Re: Please help me understand the ouput.

    I have a feeling it's defined in C++ 11. At least that's how I interpret section 5.2.6 in the standard: "The value computation of the ++ expression is sequenced before the modification of the operand...
  3. Replies
    6
    Views
    2,632

    Re: Please help me understand this question.

    As I indicated, the recursive function can be simplified and then it becomes even clearer how it works,


    void ReadListBackward(node* p) {
    if (!p) {
    printf("T!\n"); // recursion terminates
    ...
  4. Re: Help with algorithm - Delivery problem with LIFO loading

    I made a net search and found this link I think applies to your problem,

    http://www.computational-logistics.org/orlib/topic/TSPPD%20with%20LIFO%20Loading/Paper/TSPPDL.pdf

    But the...
  5. Replies
    6
    Views
    2,632

    Re: Please help me understand this question.

    It works because of recursion (a function calls itself repeatedly until a termination criterion is met).

    Here the ReadListBackward function is calling itself and each time advancing along the...
  6. Re: Help with algorithm - Delivery problem with LIFO loading

    Or you could make two roundtrips to all locations. During the first roundtrip you push all items on the LIFO as you find them. Afterwards you pop all items and immediately push them back on again in...
  7. Replies
    6
    Views
    10,972

    Re: Building bridges

    Thank you, I get it now.

    I think you've come up with a nice solution strategy. First sorting the bridges according to "from" and then finding the longest increasing subsequence among the "to"....
  8. Replies
    11
    Views
    2,729

    Re: Common base class + abstract interface class

    Well, you should never give up type information you then have to recover using downcasting at runtime.

    Since objects know what type they are you can always ask them for their type. It's what my...
  9. Replies
    11
    Views
    2,729

    Re: Common base class + abstract interface class

    One can always argue what should or shouldn't be in a top class. But the fact remains, this design strategy is very common in major OO designs such as Qt and integral to many languages such as Java...
  10. Thread: Further Reading

    by nuzzle
    Replies
    9
    Views
    2,298

    Re: Further Reading

    Dr. Dobb's has a recent list of C++ 11 books,

    http://www.drdobbs.com/cpp/c-reading-list/240155654

    In addition to this I would recommend C++ Coding Standards by Sutter and Alexandrescu, a best...
  11. Replies
    11
    Views
    2,729

    Re: Common base class + abstract interface class

    Using a top base class is quite common in OO designs actually. In both Java and C# it's even built into the language. The best known C++ example is maybe Qt where every class inherits a common top...
  12. Replies
    6
    Views
    10,972

    Re: Building bridges

    Well, if you get it please explain why bridging the third and fourth pairs is the correct solution?

    2 5 8 10
    6 4 1 2
  13. Replies
    11
    Views
    2,729

    Re: Common base class + abstract interface class

    Downcasting (including sidecasting as in this case) is bad OO and should preferably be avoided because it's not typesafe.

    In my suggestion it's established by design (and not just a known fact)...
  14. Replies
    6
    Views
    10,972

    Re: Building bridges

    Why can't you have just one bridge? That bridge would connect all cities above the river with all cities below.
  15. Replies
    11
    Views
    2,729

    Re: Common base class + abstract interface class

    You don't want to let MyInterface inherit MyBaseclass but maybe you could let MyInterface define a method which returns a pointer to MyBaseclass? Essentially that method just returns this.

    With...
  16. Replies
    18
    Views
    3,248

    Re: Self-Deleting Objects with Inheritance

    A thrown exception is not a return point.

    Multiple return points increases code complexity. Therefore they're error prone and should be avoided (although I sometimes use them myself in idiomatic...
  17. Replies
    18
    Views
    3,248

    Re: Self-Deleting Objects with Inheritance

    Reference counting smart pointers can be considered GC light, and std::shared_ptr is the standard C++ way of accomplishing "self-deleting" objects.

    Reference counting has one major drawback though...
  18. Replies
    18
    Views
    3,248

    Re: Self-Deleting Objects with Inheritance

    That would be bad programming in its own right.
  19. Replies
    4
    Views
    2,288

    Re: Hashing problem with overloaded operator

    Yes, you can do that. I would use a friend function with parameters by const reference. Const reference is the preferred passing mode if you don't intend to change the parameters.

    What I suggested...
  20. Replies
    4
    Views
    2,288

    Re: Hashing problem with overloaded operator

    Here,

    void hashT<elemType>::insert(int hashIndex, const elemType& rec)

    elemType (which is a StateData) is passed by const reference, whereas here

    // friend bool operator!=(StateData &,...
  21. Re: My Windows 8 Suggestion:Add Windows Back to Windows

    And Microsoft always do their utmost to satisfy people's desire to complain. This time they really outdid themselves. Turning desktops into handheld devices was a stroke of genius. What other move...
  22. Replies
    15
    Views
    8,640

    Re: New data type in method declaration

    A good rule of thumb is to make each class represent a single concept. So I suggest you limit Planet to represent one celestial body only, and introduce a new SolarSystem class to represent many...
  23. Replies
    2
    Views
    5,753

    Re: Help with understanding an Algorithm

    I think your best bet is to contact the author actually. If you show a keen interest in someone's work they're often very willing to discuss it with you.
  24. Re: Algorithm for finding subset of permutations with maximum value

    Well if you have an O(N^2) algorithm already you've come quite far. :)

    To me it looks like your problem is equivalent to the Weighted Interval Scheduling Problem. To see that you only have to view...
  25. Re: Algorithm for finding subset of permutations with maximum value

    Of course there exists an algorithm. This for example,

    1. Generate all possible subsets of the N "permutations". There are 2^N such subsets.
    2. From all possible subsets select the valid (no...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4





Click Here to Expand Forum to Full Width

Featured