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.08 seconds.

  1. Re: Codeguru needs a C++ programmer to write

    Is the point here just to promote (advertise?) a third party tool? I'm all for static code analysis, but I also feel that the answer should promote modern approaches and best practices that would...
  2. Re: Recursive function: take a non-negative integer and print each digit of that inte

    I think the original argument is that some problems really call for recursive solutions (for example, anything that has to do with a tree), whereas others do not (printing a number). When you want to...
  3. Re: Find all sentences or consecutive sequence of sentences where min

    Arguably, that's the biggest mistake you could make.

    A rule of thumb is to never rush, no matter what. Understand the problem to the best of your abilities. If there are still points you are not...
  4. Re: Is memory allocated to a variable name or an address?

    I assume that by "memory allocation in code" you mean "new" ?

    New makes an allocation, and then returns the address of the allocated space (if successful) in the form of a pointer. It is then up...
  5. Replies
    7
    Views
    719

    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...
  6. 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.
    ...
  7. Replies
    6
    Views
    452

    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...
  8. 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)
  9. 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())
  10. Replies
    17
    Views
    1,339

    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...
  11. Replies
    17
    Views
    1,339

    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...
  12. 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...
  13. Replies
    49
    Views
    1,718

    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...
  14. 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.
  15. 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.
  16. 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...
  17. 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...
  18. 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&...
  19. 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...
  20. 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...
  21. Replies
    17
    Views
    909

    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 =...
  22. Replies
    36
    Views
    2,122

    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...
  23. Replies
    36
    Views
    2,122

    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...
  24. Replies
    24
    Views
    983

    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...
  25. Re: Need help allocatig memory for vectorized 2D array

    The fact that it is called "C, C++ tutorial" is already a telltale sign...
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.com survey!


HTML5 Development Center