c++

When an MFC dialog is hidden after DoModal, are its controls destroyed?

I've used MFC dialogs before where you do: EnterNameDlg dlg; dlg.DoModal(); string str = dlg.GetName(); However a dialog I have now actually looks at a list-box control in such a method and it's not working. Although the class instance clearly exists after DoModal(), does the actual dialog get destroyed? I noticed calling DoModal() a ...

cpp: "-c" is not a valid option to the preprocessor

I'm trying to build a package on a RedHat system. First, I ran ./configure CXX=cpp, because /usr/bin/cpp is the C++ compiler on that system. But when I run make, it dumps: cpp: "-c" is not a valid option to the preprocessor When I do a Google search, I found a number of complaints, but no solutions. Anyone else encounter this? ...

How to extract a function from highgui module(opencv)and place in the code file

Hi, this might be a silly question, but I need to know if for the code below, if i can extract the cvCaptureFromCAM() function from the highgui.lib and paste it in my code so that I can rename it to camcapture() and then call that within my program without just including the highgui library file at the beginning of the code file: CvCapt...

Where to store Class Specific named constants in C++

If you have a class that has some named constants, what is the best practive for storing the constants: Option 1: Namespace in Class header So in my class header I will have: class myClass { ... ... }; namespace NamedConstants { const string Bucket = "Bucket"; } Option 2 Member Constants class MyClass { // this goes in th...

It is possible/productive enough to TDD in C++ projects?

Hello guys, I want to know if anyone of you guys use TDD in your c++ projects and how it performs compared to managed languages like C# and Java. And what frameworks you guys are using to automate tests on c++ projects? ...

C++ compile-time constant detection

Tbere're cases when a library source is available, and it has to support variable parameters in general, but in practice these parameters are commonly constants. Then it may be possible to optimize things by special handling of constant parameters (eg. use static arrays instead of heap allocation), but for that its necessary to determin...

tmpnam warning saying it is dangerous

I get this warning saying that tmpnam is dangerous, but I would prefer to use it, since it can be used as is in Windows as well as Linux. I was wondering why it would be considered dangerous (I'm guessing it's because of the potential for misuse rather than it actually not working properly). Thanks in advance! ...

C++ to C# conversion of SendMessage using COPYDATASTRUCT

I'm converting a C++ application into C# which has generally been fairly straight forward, but now I'm dealing with pointers and running into problems. This is the original C++ code ShockVideoInfo* pVideoInfo = new ShockVideoInfo; COPYDATASTRUCT cd; cd.dwData = bSelf ? SHOCK_REQUEST_SELFVIEW_WINDOW : SHOCK_REQUEST_MAINVIEW_WIND...

How can I shuffle a list without randomness, and guarantee that a portion of elements will eventually appear on one side?

Given a list of elements, does a shuffling algorithm exist that will guarantee that eventually a selected half portion will be on one side, and the remainder on the other? Example: { 4, 3, 10, 7, 2, 9, 6, 8, 1, 5 } Given the set above, I'd like to have a mixing algorithm that eventually moves the marked ones to the left, even though...

How do I HTML-/ URL-Encode a std::wstring containing Unicode characters?

Hi, I have another question yet. If I had a std::wstring looking like this: ドイツ語で検索していてこちらのサイトにたどり着きました。 How could I possibly get it to be URL-Encoded (%nn, n = 0-9, a-f) to: %E3%83%89%E3%82%A4%E3%83%84%E8%AA%9E%E3%81%A7%E6%A4%9C%E7%B4%A2%E3%81%97%E3%81%A6%E3%81%84%E3%81%A6%E3%81%93%E3%81%A1%E3%82%89%E3%81%AE%E3%82%B5%E3%82%A4...

rand select between n and m

here is code from programming pearls this code prints random numbers in decreasing form void randselect(m,n){ pre 0<=m<=n; poset : m distinct integers from 0 ...n-1 printed in decreasing form if (m>0) if ( bigrand() %n)<m print n-1//here i dont understand print n-1 what means?printf(n-1) or?i will show code randselect(m-1.n-1...

How does one convert cdt managed to makefiles?

Hi stackoverflow, Recently I started doing a C++ project, and started it using the internal building tools of eclipse, which seemed the easiest approach to this. However, because this project will need to be built on more than one architecture, I figured it was best to have some other approach of building this on the other architecture...

Cast to int vs floor

Is there any difference between these: float foo1 = (int)(bar / 3.0); float foo2 = floor(bar / 3.0); As I understand both cases have the same result. Is there any difference in the compiled code? Note: updated fabs() to floor() as that was the real question ...

file name matching with wildcard

Hello, I need to implement something like my own file system. One operation would be the FindFirstFile. I need to check, if the caller passed something like ., sample*.cpp or so. My "file system" implementation provides the list of "files names" as a array of char*. Is there any Windows function or any source code that implements this ...

Project Idea in Python or C#

Hi So far I was familiar with c and c++ only, and I have programmed in these languages only. I have some experience working on some projects in c or c++. Some good projects or applications I've made till now: Duplicate file finder and remover Process monitor on Linux Basic http proxy server I have made one small flex application ...

Super high performance C/C++ hash map (table, dictionary)

I need to map primitive keys (int, maybe long) to struct values in a high-performance hash map data structure. My program will have a few hundred of these maps, and each map will generally have at most a few thousand entries. However, the maps will be "refreshing" or "churning" constantly; imagine processing millions of add and delete m...

In what ways can a class access members of another class?

Earlier, I asked a question on how to call a static member's member functions so as to initialize it before making actual use of the static object. Then, I realized that I was perhaps making use of the static member in a wrong way, which led to this question: Given a particular class, MyClass, in how many ways can we design our code so ...

C++ templates and "no matching function to call"

I'm getting a strange error. I have a function of the following signature: template <typename DATA, DATA max> static bool ConvertCbYCrYToRGB(const Characteristic space, const DATA *input, DATA *output, const int pixels) { Which is later called like this: case kByte: return ConvertCbYCrYToRGB<U8, 0xFF>(space, (const U8 *)input, (...

I want to see if a character is present in a string.

Hi, I'm programming a program in C++ (typical game) in which you need to guess a letter and it will check if it is present in a string. For example Secret String: I like to program. Guess1: 'a' Display: . .... .. .....a... Etc. But i don't know how to see if a character is in this secret string. I'm using std::string (obligatory)...

bind() for using member function as STL comparison function

Could someone tell me why the following won't compile? #include "a.h" #include <list> #include <algorithm> #include <tr1/functional> using namespace std; class B { public: B() { list< A* > aList; A* a = new A(); lower_bound( aList.begin(), aList.end(), a, tr1::bind( &B::aComp, tr1::placeholders::_1, tr1::placeh...