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

Search:

Type: Posts; User: monarch_dodra

Page 1 of 80 1 2 3 4

Search: Search took 0.09 seconds.

  1. Replies
    5
    Views
    165

    Re: stl map with two keys

    "Invalid Iterator" might be a missleading message here. Or at least. Not very helpful. It is only a consequence of the fact that key you are looking for is missing. So "Key not found in...
  2. Re: How to make a std::map return null when there is nothing "at" a certain position?

    The advantage here is simply locality. You avoid poluting your namespace/class with single use helpers. Furthermore, when using said helper, you don't need to look very far to find its definition.
    ...
  3. Replies
    6
    Views
    314

    Re: Hexagon Grid

    It really depends on how you define your grid. Do you move *along* the edges of your hexagons? Or are the hexagons themselves simply cells, and you can move in any 6 directions.

    AFAIK, you can't...
  4. Re: How to make a std::map return null when there is nothing "at" a certain position?

    Fine: "And I most certainly would NOT use at if I plan to IMMEDIATELY handle it." (https://isocpp.org/wiki/faq/exceptions#too-many-trycatch-blocks)
  5. Re: How to make a std::map return null when there is nothing "at" a certain position?

    I'd go for either:


    auto it = unitColors.find(unit->id);
    auto color = it != unitColors.end() : *it ? DWord{0};



    auto color = DWORD{0};
    if (unitColors.find(unit->id) != unitColors.end())
  6. Replies
    17
    Views
    1,112

    Re: Sorted vector/list to set

    Actually, I wasn't too worried about subsequent lookup/insertion, as I knew that the container is guaranteed balanced and has log(n) guaranteed performance. I was actually worried that the initial...
  7. Replies
    17
    Views
    1,112

    Re: Sorted vector/list to set

    Hi, I'm necro-ing this 6 year old thread. I stumbled upon it while searching for something else, and decided to follow up on this, as I found interesting information.

    So I actually benchmarked...
  8. Re: error: expression must have a class type

    As a rule of thumb, prefer using "vector::data()" than "&vector[0]": It is more idiomatic in the sense that you use a function specifically designed explicitly for this use case. More importantly...
  9. Replies
    49
    Views
    1,284

    Re: .xml to .txt

    I usually just use tinyxml (http://www.grinninglizard.com/tinyxml/). It is a very lightweight, easy to install and very simple to use. It doesn't have a ton of features: you just give it an xml...
  10. Re: Dequeuing Integer Values From Heap Results In Garbage Values

    Do yourself a favor and Learn to use a debugger. The debugger would have told you that faster than it took you to copy paste your code here.
  11. Re: If I run the same program twice under linux

    Pretty sure that "If I run the same program twice under linux", then nothing will be shared in memory.
  12. Replies
    12
    Views
    533

    Re: Basic operator overloading

    These are good reading, but (IMO), both fail to recognize that having (certain) functions as members is simply convenient from a user's point of view. Just because you can, doesn't always mean you...
  13. Replies
    12
    Views
    533

    Re: Basic operator overloading

    For operator=, checking for that this and the right hand side are the same is usually a good idea. But if you can write your code in such a way that it does not matter, that's equally good. Also, for...
  14. Replies
    12
    Views
    533

    Re: Basic operator overloading

    This should be pretty trivial. Just make them return a reference "vmSize&", and at the end of your function, return a reference to this "return *this". That's really all there is to it:


    vmSize&...
  15. Replies
    12
    Views
    533

    Re: Basic operator overloading

    The usual standard practice is to make binary operators non-member fields. In this case it does no change much (if at all), just know this exists.

    Also, from a style point of view, in C++ the...
  16. Re: unsigned char* to string& being passed into function

    I have to disagree with this answer. The memory block itself is assigned to msg, and valid (though its contents are rubish, yes).

    Even then, string has a constructor that takes a buffer, and a...
  17. Replies
    17
    Views
    673

    Re: Working with fractions

    The design of your sum is wrong. It should return a new fraction "Fraction sum(Fraction a, Fraction b)", and then you want to print *that*. For example:


    sum(a, b).proper();
    // or
    Fraction c =...
  18. Replies
    36
    Views
    1,734

    Re: Seeding a C++11 random

    I mean that C has a "ready to use" global PRNG that you only need to seed once for the global application. C++11 has a lot of PRNG *types* but no global PRNG for sharing.



    That is a good...
  19. Replies
    36
    Views
    1,734

    Seeding a C++11 random

    I was wondering if there was a recommendation in regards to seeding C++11 randoms.

    The thing is that C-rand can be seeded with time, as it is a global random that only gets seeded once (though...
  20. Replies
    24
    Views
    846

    Re: Functionality of a function?

    Honestly, no. Please ask a clear question, so that we can provide a clear answer.

    You mentioned insertAsFirstElement so I will take a look at that.

    Also, please put your code in
    tags, to...
  21. Re: Need help allocatig memory for vectorized 2D array

    The fact that it is called "C, C++ tutorial" is already a telltale sign...
  22. Re: Need help allocatig memory for vectorized 2D array

    Yeah, the take home point here is that "[][]" is a bad idea. "(x, y)" (or "get(x ,y)" if you don't like operator()) is the way to go.

    An argument in favour of "[]" is that it could return an...
  23. Replies
    4
    Views
    442

    Re: Error 127 - Process not found

    If your error is "Error 127 - Process not found", the it is not a C++ problem, but an environment/program problem. There is absolutely nothing wrong with your program, which should work as-is....
  24. Replies
    6
    Views
    466

    Re: Variable declaration syntax?

    Actually, we should now prefer uniform initialization, and possibly, the "almost always auto" anitialization.
  25. Re: Handing more than one exception at a time

    Yes, it did not disprove the UB. It did disprove the "If you do it anyways, it terminates". Which was kind of my point that both statements are contradictory (you can't have UB if the standard...
Results 1 to 25 of 2000
Page 1 of 80 1 2 3 4


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center