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

Search:

Type: Posts; User: razzle

Page 1 of 25 1 2 3 4

Search: Search took 0.06 seconds; generated 50 minute(s) ago.

  1. Re: Compiler Error C2512: 'Coordinater' : no appropriate default constructor availabl

    But is the Coordinater definition known to CPF_Thread when it is defined? The cpf_thread.h file should look something like this,



    #include "Coordinater.h"

    class CPF_Thread
    {
    // ....
    };
  2. Thread: Integer Range

    by razzle
    Replies
    18
    Views
    6,449

    Re: (Resolved) Integer Range

    Thank you, you are as just as they come.
  3. Replies
    25
    Views
    20,726

    Re: Vector of Templates Problem

    Could you please be more specfic.

    What is this feature of Python you are looking for in C++?

    I can tell you right now that if you give up information there is no way of getting it back unless...
  4. Re: Help Pleasse! Beginning C++ program (can't debug)

    In an educational situation "working" may not be good enougth. Maybe the code should be of a certain quality reflecting what you have been taught.

    Why not ask the teacher to be more specific...
  5. Replies
    25
    Views
    20,726

    Re: Vector of Templates Problem

    Well, an include guard will take care of the linker problem.

    Regarding many types in a vector I strongly advice you to seek a solution that avoids downcasting. The most common way is to declare...
  6. Replies
    25
    Views
    20,726

    Re: Vector of Templates Problem

    You can store any pointer data type already in a vector since you can upcast any pointer to void*. And you can always downcast a void* pointer again to its actual type although this will not be...
  7. Replies
    25
    Views
    20,726

    Re: Vector of Templates Problem

    It appears to have been submitted already,

    http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3804.html
  8. Replies
    25
    Views
    20,726

    Re: Vector of Templates Problem

    You need to add an include guard. Otherwise the compiler will generate a function in each compilation unit. The linker will then find several versions of the same function.

    One way (if you use...
  9. Thread: Integer Range

    by razzle
    Replies
    18
    Views
    6,449

    Re: (Resolved) Integer Range

    Dear quorsum,

    On behalf of the rest of us I would like to extend an appology. Despite our sincere efforts our replies must have blocked your thinking and so of course we don't deserve even a thank...
  10. Re: Just wondering what the equivalence of this method is for C++?

    Well, the OP wanted equivalence and returning f is closer to the original.



    I agree it may be safer to rule out NaN first and since the order doesn't matter logically I change my suggestion...
  11. Re: Just wondering what the equivalence of this method is for C++?

    The Java function can be used pretty much as written. Here's a C++ 11 template version to handle both float and double:



    #include <cmath>

    template<typename T>
    T signum(T f) {
    return...
  12. Re: Just wondering what the equivalence of this method is for C++?

    I think "return 0.0;" should rather be "return f;" to conform with the original.



    But std::isnan in <cmath> is overloaded both for float and double.



    Why is that? For an || logical...
  13. Replies
    9
    Views
    2,145

    Re: Problem with empty/null string/char...

    Only you know since you're not telling how you compare.

    Have you printed what file_name points at so you know it is '\0' indeed?

    Are you sure you are comparing what file_name points at and not...
  14. Replies
    2
    Views
    7,362

    Re: How to get the address of 1st node in

    The STL containers don't give you access to implementation detail like say internal pointers.

    What you could do is push the elements on stack, clear the list, and then rebuild it with the elements...
  15. Re: How to make a std::map return null when there is nothing "at" a certain position?

    Locality? It beats me why you consider this,



    void foo() {
    auto unitColors_at_or_zero = [&]( auto id ){ auto it = unitColors.find(id); return it != unitColors.end() ? *it : 0; };
    DWORD...
  16. Thread: Integer Range

    by razzle
    Replies
    18
    Views
    6,449

    Re: Integer Range

    That works for me too. :)

    But there's a certain amount of implementation dependency at play here and it's never wrong to be explicit about the literal type.

    Also it seems in C++ 11 it's...
  17. Thread: 3d vector

    by razzle
    Replies
    11
    Views
    2,472

    Re: 3d vector

    You don't have to do anything special. You can treat it like you would an int or double.
  18. Thread: Integer Range

    by razzle
    Replies
    18
    Views
    6,449

    Re: Integer Range

    To denote a long long literal you need to add one of the suffixes l or L like

    long long test = 5000000000L;
  19. Re: How to make a std::map return null when there is nothing "at" a certain position?

    That's typical feature overuse. Something a pumped up newbie would put in to show off. You get the worst of two worlds:

    As implementation it's too much. What's wrong with a simple free function? ...
  20. Re: How to make a std::map return null when there is nothing "at" a certain position?

    Certainly (as all replies show) but regardless of how you decide to do it I suggest you encapsulate the map, the initialization of the map and accesses to the map in a class called say UnitColors...
  21. Re: What is the best matching data structure for C# binary heaps in C++ with boost?

    As an abstract data type a heap is called a priority queue so that's what you should be looking for.

    The C++ standard library has one called std:: priority_queue and I'm quite certain there is one...
  22. Replies
    6
    Views
    5,625

    Re: Increment or double problem

    Recursive problem formulations are often succinct and elegant but they have their fair share of problems in practice. One is the risk of running out of stack space, another is the relative slowness...
  23. Replies
    6
    Views
    5,625

    Re: Increment or double problem

    Well, my intention was just to clarify the recursive solution in principle.

    Optimization is another story.

    The dictionary strategy they suggested probably was a memoization attempt to avoid...
  24. Replies
    6
    Views
    5,625

    Re: Increment or double problem

    That is a recursive formulation of the problem. In code it would look like this,



    int count(int a, int b) {
    if (a>b) return 0; // no solution
    else if (a==b) return 1; // one solution
    ...
  25. Replies
    5
    Views
    1,279

    Re: How to return a multidimensional array?

    If you plan to return a pointer to the 2D array you are asking for trouble. Chances are it gets stale and there will be a much harder to find runtime bug.

    The most immediate solution is to return...
Results 1 to 25 of 614
Page 1 of 25 1 2 3 4





Click Here to Expand Forum to Full Width

Featured