Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
Unknown Quality Score

No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.

~28.1K People Reached
Member Avatar for Jsplinter

I do not understand what the following code does: enum testEnum: unsigned char { FOO_ENUM, BAR_ENUM }; unsigned char sideFilter1 = 1 << FOO_ENUM; unsigned char sideFilter2 = (1 << FOO_ENUM) | (1 << BAR_ENUM);

Member Avatar for NathanOliver
0
182
Member Avatar for Jsplinter

So, I've gotten myself in a bit of a pickle. I have been serializing data I collect with: vector<myClass> mVec; ... // mVec is filled with the data to collect for (auto it = mVec.begin(); it != mVec.end(); ++it) { myfile.write(reinterpret_cast<char*>(&(*it)), sizeof(*it)); } I've wrapped this code in a templated …

Member Avatar for Ancient Dragon
0
2K
Member Avatar for cambalinho

i continue with 1 problem with emails notifications and i have the option selected :( - if i'm log out/off, i recive the mails notifications normaly(new posts and private message); - if i'm log in, i only recive the mails notifications about the private messages :( for see that someone …

Member Avatar for cambalinho
0
627
Member Avatar for Jsplinter

I have an array of 3,000 floats: `float *mVec = new float[3000];` and I need to take the log of each element. I am translating MATLAB code, in which everything is vectorized (ie, log(mVec) does some parallelization behind the scenes). There must be a better way to do this than …

Member Avatar for mike_2000_17
0
199
Member Avatar for Jsplinter

I have a container object which contains float*. struct MyCon{ MyCon(){ matA = new float[10]; matB = new float[10]; } float *matA; float *matB; } And, I am storing pointers to MyCon objects in a std::map. map<string, MyCon*> myCon_map; myCon_map.insert(pair<string,MyCon*>(string("str"), new MyCon())); Once I am finished with myCon_map, how do …

Member Avatar for JasonHippy
0
578
Member Avatar for Jsplinter

I have an mxn matrix, that is stored in memory in an array: matA = new float[m * n]; // ... Assign values matA[0] = 1; matB[1] = 2; // ... After I finish with this array, I then need to create very similar array to store a new mxn …

Member Avatar for Jsplinter
0
264
Member Avatar for Jsplinter

If I have a function that takes a ref argument like: void Foo(ref int i, int b, int c){ i = b + c; } and I want to call that function with the ref int i argument determined conditionally: int q, r; bool bTest; //... if (bTest) { bar(ref …

Member Avatar for darkagn
0
122
Member Avatar for Jsplinter

I have the following lines of code, where an if statement compares two strings: string strFound = @"Testing"; string strTest = @"Testing"; if (strFound.Equals(strTest)) { ++iCount; // This line executes when strFound == strTest as expected } if (!(strFound.Equals(strTest))); { ++iCount;// Surprisingly this line always executes even when strFound == …

Member Avatar for JOSheaIV
0
212
Member Avatar for Jsplinter

I understand how to write a function to loop through a vector<double> and calculate the mean and standard deviation of its values, but I was wondering if there is a library which I could simply #include<> and then just call a function to compute such values.

Member Avatar for Jsplinter
0
246
Member Avatar for Jsplinter

About 11 months ago I started this [thread](http://www.daniweb.com/software-development/cpp/threads/386863/declaring-const-int-causes-error-c2582-operator-function-is-unavailable) asking why I couldn't use a const data member in a class that was going to be used in an stl container. The explanations were excellent. Now my question is, what is the best alternative to having a class with BOTH a) …

Member Avatar for mike_2000_17
0
266
Member Avatar for Jsplinter

I wrote the following code to test which is faster: performing a multiplication and division many times, or accessing the results in a vector via iterators(perform the calculations ahead of time), or hard coding the results of those calculations into the program. I actually expected storing the results in the …

Member Avatar for Jsplinter
0
265
Member Avatar for happygeek

I became a grandad for the fourth time today. Gracie is beautiful. Later thus week I will find out if I am going blind in one eye and how long that process will take, and importantly if it will spread to the other eye. Final tests on Friday, in the …

Member Avatar for mike_2000_17
3
232
Member Avatar for Jsplinter

I'd like to represent an integer with a value between 0-100,000. Unsigned short int (range 0-65535) is too small. Unsigned int (range 0 - 4294967295) is big enough, but for a large data set this wastes a lot of space. Does there already exist a class that is in between? …

Member Avatar for Jsplinter
0
4K
Member Avatar for Jsplinter

[CODE] vector<int> iv; iv.push_back(4); vector<int>::iterator it = iv.begin(); cout << *it; cout << *(iv.begin()); //debug assertion here [/CODE] Why can't I dereference iv.begin() directly?

Member Avatar for Jsplinter
0
273
Member Avatar for Jsplinter

class MapClass holds copies of class DataStruct so that instances of class Action only have to store the key value associated with the DataStruct: [CODE]struct DataStruct { friend bool operator< (DataStruct const &lhs, DataStruct const &rhs) { if (lhs.xData < rhs.xData) return true; else if (lhs.xData > rhs.xData) return false; …

Member Avatar for Jsplinter
0
136
Member Avatar for Jsplinter

Any idea why declaring a const int inside a data member of a class would cause error C2582: 'operator =' function is unavailable in 'CMyClass'? There is a lot going on in CMyClass and I don't know where to start looking for the error. I am using the default operator= …

Member Avatar for mike_2000_17
0
588
Member Avatar for Jsplinter

I am trying to write a class which holds either a pointer to an object of class A(base) or class B(derived) depending on conditions at run time. The base class and derived class: [CODE] class A { protected: int x; }; class B : public A { public: int y, …

Member Avatar for gerard4143
0
150
Member Avatar for Jsplinter

I've tested the following code in a console application, and it compiles just fine. However, when I copy it to a header to include in a larger project, I get 77 link errors, all related to boost. If I comment out the line in [COLOR="red"]red[/COLOR], everything compiles just fine without …

Member Avatar for pseudorandom21
0
438
Member Avatar for Jsplinter

I am following this [URL="http://www.boost.org/doc/libs/1_37_0/libs/serialization/doc/index.html"]example [/URL]to serialize an object with boost. However, I keep getting the same compile error: error C2248: 'boost::scoped_ptr<T>::scoped_ptr' : cannot access private member declared in class 'boost::scoped_ptr<T>' Any idea why? [CODE]// Console2.cpp : Defines the entry point for the console application. #pragma once #include "stdafx.h" #include …

Member Avatar for mitrmkar
0
372
Member Avatar for Jsplinter

I want to iterate through a list of objects, then erase all objects from the list which meet a certain criteria. Here is an example using int type as my object: [CODE] list<int> m_list; // Fill list with int values... // Find ints == 4 and erase them auto it …

Member Avatar for Narue
0
225
Member Avatar for Jsplinter

How do I invoke the int operator < instead of the int* operator < ? [CODE] vector<int*> pVec; std::sort(pVec.begin(),pVec.end(), /*????*/); [/CODE]

Member Avatar for Jsplinter
0
4K
Member Avatar for Jsplinter

Is there a more efficient way to do this? [CODE] vector<int> myvec; vector<int>::iterator it; /////// // Count # of iterations int i = 0; while ( it != myvec.end() ) { ++it; ++i; } [/CODE] Just seems expensive to me.

Member Avatar for Narue
0
115
Member Avatar for Jsplinter

I'm just starting a search for a library or code sample for grouping numbers together based on their distance from one another. For instance, in the set{1,2,4,25,28,29}, is there an algorithm that would identify two groups of numbers subsetA{1,2,4} and subsetB{25,28,29}? Nothing really came up in my google search, but …

Member Avatar for Jsplinter
0
247
Member Avatar for Jsplinter

Is there a better way to access the base class operator overload? I'm using casting, and it works just fine, just wondering if there is a better way. Is this bad/ugly code? [CODE]class StrategyKey { public: StrategyKey(){} ~StrategyKey(){} StrategyKey(const char* strA): str_strategy(strA) {} friend bool operator< (const StrategyKey& stratKeyA, const …

Member Avatar for mrnutty
0
172
Member Avatar for Jsplinter

I am using a map in the standard way. It holds keys and values and sorts them by key and works wonderfully. However, after I am through adding to the map, I need to rank the keys based on their associated values. What is the best solution? A) Take map<myKey, …

Member Avatar for mike_2000_17
0
4K
Member Avatar for Jsplinter

I'm having trouble overloading the operator< for a class that I want to use as a key for an stl map. It works fine for a comparison test, but when I try to use the std::map.find() function I get an error: [I]binary '<' : no operator found which takes a …

Member Avatar for mike_2000_17
0
2K
Member Avatar for Jsplinter

All things equal, does an object of a class which has methods take up more memory resources than an instance of a class without methods. What if it is a vector of such objects? For example: [CODE] class A{ public: void DoSomething(); void DoSomethingelse(); private: int x, y; }; class …

Member Avatar for mike_2000_17
0
135
Member Avatar for Jsplinter

I have a nested class declared as: [CODE]class A { class B { // members }; // members }; [/CODE] Is there a good way to avoid typing A::B every time I need to access B's members? I'd just like to do this in one .cpp file. I tried "using …

Member Avatar for Jsplinter
0
223
Member Avatar for Jsplinter

Below is a simplified version of the function. [code]int x; void myAdd(const double& p) { if (x > 100) { x = 1; myAdd(p); } ++x; ... }[/code] The advantage of this recursion is that I don't have to write a second function ie myAdd2. Are there any pitfalls of …

Member Avatar for mike_2000_17
0
114
Member Avatar for Jsplinter

If I'm creating a new char[] to read in a text file: [code]char* pbuffer; pbuffer = new char[length]; [/code] what is the maximum size length can be? Would a std::string be better? pbuffer will only be allocated one time in scope no matter what, and length is not known until …

Member Avatar for Jsplinter
0
150