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.

41 Posted Topics

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
184
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 am not receiving e-mail notifications for my "Watched Articles." I've double checked my spam folder and e-mail address on file. Is there a setting to turn on e-mail notifications? My initial search did not find one.

Member Avatar for cambalinho
0
629
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
204
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
723
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
281
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
124
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
216
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
266
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
280
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
269
Member Avatar for happygeek

Congratulations on the grandchild! I'm sad to hear that such a strong contributor to daniweb is losing their sight. Maybe you can be as prolific as the great Leonhard Euler, who lost sight in one eye, but continued making discoveries. I wish you well, and encourage you to eat wild …

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
281
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
138
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
598
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
154
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
450
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
376
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
232
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
5K
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
116
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
257
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
176
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
137
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
225
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
130
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
156
Member Avatar for Jsplinter

I am trying to read in user input which is a file path (riddled with escape characters) into a CString. How can I do this without asking the user to replace '' with '\'? For instance: [code] CString myString; myString = _T("c:\test\file\j\mypath\path\user.bin"); wcout << myString.GetBuffer(myString.GetLength()) << endl;[/code] outputs: c: estQilejmypathpathuser …

Member Avatar for Jsplinter
0
279
Member Avatar for Jsplinter

I've read the documentation [URL="http://msdn.microsoft.com/en-us/library/ms644906(VS.85).aspx"]link[/URL] and several threads explaining how to make a timer. Now after hours I still can't get my test to work. In the testDlg.h header I declare: [code] UINT_PTR m_uTimerId; CString textControl1; // Controls an Edit Control afx_msg void OnBnClickedButton1(); afx_msg void OnTimer(UINT_PTR nIDEvent); int myX;[/code] …

Member Avatar for Jsplinter
0
1K
Member Avatar for Jsplinter

My program passes a parameter that looks like this: [CODE]std::vector<myDataType> vec; void function(&vec);[/CODE] Then the function accepts the argument like this: [code]void function(std::vector<myDataType>* myVec){ ...does something }[/code] Yet somehow I am getting the following error: error C2664: 'CMyClass::WriteVectorSTL_CSV' : cannot convert parameter 1 from 'std::vector<_Ty> *__w64 ' to 'std::vector<_Ty> *' …

Member Avatar for Intrade
0
228
Member Avatar for Jsplinter

The following code generates an error when the [code]//vector<int> myVofInt2(n);[/code] line is uncommented. I get: error C2059: syntax error :'constant'. Does anyone know why it treats the declaration/initializations differently when the vector is inside a class? The vector<int> in the main function creates a vector<int> with ten elements, which is …

Member Avatar for Jsplinter
0
174
Member Avatar for Jsplinter

I am trying to trigger an event to run after ten minutes of idleness (as in no mouse or keyboard input). I created a task with the task scheduler, but it is not being triggered no matter how long my computer is idle. I set the trigger "When computer is …

Member Avatar for Jsplinter
0
271
Member Avatar for Jsplinter

I created a tasks in the task scheduler called VS2010R which opens devenv.exe on demand. I've tested it from the task scheduler and it runs fine. However, I am unable to run this task from the command window. When I input: [code] C:\Users\mini>SCHTASKS /RUN /TN "VS2010R" [/code] I get: ERROR: …

Member Avatar for Jsplinter
0
292
Member Avatar for Jsplinter

I have data stored in a deque that I wish to write to disk using fstream. So far this is the test code I have written. [code] int j = 10000; deque<double> m_data; for(int i = 0; i < j; i++) { m_data.push_back(i); } std::fstream myfile; myfile.open ("data2.bin", std::ios::out | …

Member Avatar for Jsplinter
0
2K
Member Avatar for Jsplinter

I am getting this error even though a) the header file does exist and is located in the directory and it's not somehow been switched to read only. Also, my #include statement uses "" like "test.h" so the compiler knows to look in the project directory first. I've read that …

Member Avatar for Jsplinter
0
361
Member Avatar for Jsplinter

Simply put I wish for text entered in one edit box to then appear in another edit box. I have created a MFC dialog and read many tutorials, but I'm still stuck. Here is my current DDX function: void Ctextentry23Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT1, name); DDV_MaxChars(pDX, name, 20); DDX_Text(pDX, …

Member Avatar for Jsplinter
0
537
Member Avatar for dadam88

That is an infinite loop. Try replacing the OR operators with AND operators. [code]while(pick != 'r' && pick != 'g' && pick != 'b') {}[/code]

Member Avatar for arkoenig
0
93
Member Avatar for Jsplinter

I am trying to write an if statement to test whether two conditions are both true. However, my code does not work when I combine the both tests into one if statement like: [CODE] if((last_smallest < samples[i]) && (samples[i] < current_smallest)) current_smallest = samples[i]; [/CODE] I know it is possible …

Member Avatar for Jsplinter
0
112

The End.