December 3rd, 2009 09:23 AM
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++)...
December 2nd, 2009 04:58 PM
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...
December 1st, 2009 02:51 PM
This seems appropriate:
Excerpted from http://www.softpanorama.org/Lang/Cpp_rama/humor.shtml.
November 24th, 2009 08:35 AM
No extra copies...
void doitVecNew() {
cout << "doitVecNew:\n";
cout << " create myVec<MyClass*>...\n";
vector<MyClass*> myVec;
cout << " populate myVec (push_back(new...
November 24th, 2009 08:21 AM
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...
November 24th, 2009 06:43 AM
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...
November 23rd, 2009 02:29 PM
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())...
...
November 23rd, 2009 10:16 AM
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...
November 23rd, 2009 07:13 AM
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...
November 20th, 2009 02:51 PM
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
...
November 20th, 2009 01:38 PM
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...
November 20th, 2009 01:28 PM
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....
November 4th, 2009 01:32 PM
The set seems to work nicely. Easier to erase items, too.
#include <vcl.h>
#include <set>
#include <iostream>
#pragma hdrstop
using std::cout;
November 4th, 2009 12:59 PM
Cool, thanks, I will probably use that.
November 4th, 2009 12:58 PM
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...
November 3rd, 2009 02:45 PM
That worked, thanks!
(Somehow that syntax seems backwards to me, I didn't think of it..)
November 3rd, 2009 01:54 PM
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?
...
November 3rd, 2009 01:42 PM
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...