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

Search:

Type: Posts; User: cpengr

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    1,572

    Re: Convert vector to vector?

    Thanks for your input.

    I find functors a bit obtuse, and I've spent more time on this than I should...just brute-forcing it...


    uint16_t sum = 0;
    for (int i=0; i<byteVec.size(); i++)...
  2. Replies
    4
    Views
    1,572

    Convert vector to vector?

    Hi all,

    I'd like a code-concise way to find a modulo (2^16) sum of a vector<uint8_t>. i.e. The bytes are grabbed in pairs, and summed into an unsigned short (uint16_t). I tried making a...
  3. Re: static function to call member function on all objects?

    This seems appropriate:

    Excerpted from http://www.softpanorama.org/Lang/Cpp_rama/humor.shtml.
  4. Re: static function to call member function on all objects?

    No extra copies...


    void doitVecNew() {
    cout << "doitVecNew:\n";
    cout << " create myVec<MyClass*>...\n";
    vector<MyClass*> myVec;
    cout << " populate myVec (push_back(new...
  5. Re: static function to call member function on all objects?

    Well, you do not have the manage the memory of the dynamic array of pointers even though you have to manage the memory for the object associated with each pointer.[/quote]
    Good point. I think maybe...
  6. Re: static function to call member function on all objects?

    That crossed my mind. Ironically, part of what drew me to STL containers was not having to manage memory...oh well, guess I can't have my cake & eat it, too...but I do like to know what kinds of...
  7. Re: static function to call member function on all objects?

    Ah-hah! That helps clarify what's happening, thank you.




    Okay, so by adding a copy constructor, and disallowing assignment (and subsequently remming assignments in doit())...


    ...
  8. Re: static function to call member function on all objects?

    Thanks for the detailed answer (including the part I'm not quoting here).



    Factory pattern, hrm. I did a little reading, and...this is starting to seem like more trouble than it's worth. I...
  9. Re: static function to call member function on all objects?

    Ah, I had forgotten.


    Are you saying that the objects are being copied, or that the pointers are being copied?
    1.) If the objects are being copied, why? The container only holds pointers to...
  10. Re: static function to call member function on all objects?

    Thanks for your reply. I think there is more going on here than that, though. My compiler settings seem to show no optimizations:

    Project -> Options -> Compiler -> Code optimization = None
    ...
  11. Replies
    16
    Views
    1,619

    Re: initializing static array

    If values are known at compile-time:
    http://www.velocityreviews.com/forums/t280275-initialize-an-static-array-in-a-class.html

    If you need to use the for-loop, or if the values will be calculated...
  12. Re: static function to call member function on all objects?

    Upon further inspection, this code, does not behave as I expected. The code is shown below, followed by its output.

    Questions:

    1.) In doit(), object #4 is destroyed right after it is created....
  13. Re: static function to call member function on all objects?

    The set seems to work nicely. Easier to erase items, too.



    #include <vcl.h>
    #include <set>
    #include <iostream>
    #pragma hdrstop

    using std::cout;
  14. Re: static function to call member function on all objects?

    Cool, thanks, I will probably use that.
  15. Re: static function to call member function on all objects?

    I couldn't figure a way to implement this. An "update individual" member function needs to be called once on every object when the static "update all" function is called. If I e.g. have a bool...
  16. Re: static function to call member function on all objects?

    That worked, thanks!

    (Somehow that syntax seems backwards to me, I didn't think of it..)
  17. Re: static function to call member function on all objects?

    I'm not sure what syntax I would use for this. (I made a couple attempts already.)

    Also, for this simple dummy example, I would think I could just define it below the declaration. Correct?

    ...
  18. static function to call member function on all objects?

    Hello all,

    I'm working in Borland C++ Builder v6.0 (maintenance/rewriting some code). I have a class where I'd like to have a static function call a member function on all instantiated members of...
Results 1 to 18 of 18


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center