c++

Large number of simultaneous long-running operations in Qt

I have some long-running operations that number in the hundreds. At the moment they are each on their own thread. My main goal in using threads is not to speed these operations up. The more important thing in this case is that they appear to run simultaneously. I'm aware of cooperative multitasking and fibers. However, I'm trying to...

using exit(1) to return from a function

Hello, linux gcc 4.4.1 C99 I am just wondering is there any advantage using the following techniques. I noticed with some code I was reading the exit number went up in value, as displayed in this code snippet. /* This would happen in 1 function */ if(test condition 1) { /* something went wrong */ exit(1); } if(test condition...

Web browser event log

I have to develop a console application that would monitor and list all the events fired by browsers: Internet Explorer 8, Mozilla Firefox and Google Chrome. What topics need to be studied? Can you help me in some ways? ...

vim - indentation of C++ constructor initialization list problem

I'm using vim 7.0. I want the following code be indented in the following way (initialization list in the same indentation as constructor): A::A() : a1(10), a2(10), a3(10) { } According to vim help this can be done by setting: set cino+=i0 But this setting yields (only a1 is indented correctly): A::A() : a1(10), a...

Tracking Lua tables in C

I have C++ objects and I have Lua objects/tables. (Also have SWIG C++ bindings.) What I need to be able to do is associate the two objects so that if I do say CObject* o1 = getObject(); o1->Update(); it will do the equivalent Lua: myluatable1.Update(); So far I can imagine that CObject::Update would have the following code: void ...

Code compiles locally on g++ 4.4.1, but not on codepad.org (g++ 4.1.2)? (reference to reference problem)?)

I was writing a test case out to tackle a bigger problem in my application. I ended trying some code out on codepad and discovered that some code that compiled on my local machine (g++ 4.4.1, with -Wall) didn't compile on codepad (g++ 4.1.2), even though my local machine has a newer version of g++. Codepad calls this a reference to refe...

Qt: Dragging a widget to scroll the widget's parent QScrollArea?

I've got a long horizontal QLabel displaying a png (the image shows a signal/time graph). Under that, I've got a QTableWidget. Both of these are in a QScrollArea because I want them to stay vertically aligned (the cells in the table correspond with the signal seen directly above them). I'm trying to add a handler to the QLabel such that ...

errors in VS2008.

I have created one application in VS2005. It is working perfectly. But when i am building same application in VS 2008 it is showing these errors please help. C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(771) : error C2065: ‘T’ : undeclared identifier C:\Program Files\Microsoft Visual Studio 9.0\VC\...

Calculate the gradient for an histogram in c++

I calculated the histogram(a simple 1d array) for an 3D grayscale Image. Now I would like to calculate the gradient for the this histogram at each point. So this would actually mean I have to calculate the gradient for a 1D function at certain points. However I do not have a function. So how can I calculate it with concrete x and y value...

vector multiple definition link errors

vector is included in only one source file. The only stl include in the header files is string. Yet I cannot get rid of multiple definition errors (example below). Any ideas? ./plugin_dfb.o:mipsel-linux-uclibc/include/c++/4.2.0/bits/stl_bvector.h:182: multiple definition of `std::operator-(std::_Bit_iterator_base const&, std::_Bit_itera...

c++ boost::thread sleep()

Hi, I am currently working on a small wrapper class for boost thread but I dont really get how the sleep function works, this is what I have got so far: BaseThread::BaseThread(){ thread = boost::thread(); bIsActive = true; } BaseThread::~BaseThread(){ join(); } void BaseThread::join(){ thread.join(); } void BaseT...

Can you place a complex condition into a for loop?

while (status) for (int i = 0; i < 3; i++) Is the following syntactically correct: for (int i = 0; i < 3; i++ && status) I am trying to have the for loop break early if status is true. ...

tool to convert c++ source code to flow chart

I have an old C++ code with multiple nested if else Is there a tool that will take C++ code and produce a flow chart ? a free tool will be the best ;-) ...

Extreme big/small number programming.

I am trying to do some extreme precise maths calculation of very big/small number. The very big number may have 10 - 50 digits and the very small number may have 10 - 50 decimal places. Can C++ do this? If not is there any other programming language that can handle this kind of number? ...

Good short and freely downloadable STL tutorial

I want to refresh my STL knowledge before interview. Could anyone recommend good short and freely downloadable STL tutorial? Thank you. EDIT: Preferably in PDF. ...

Using reference as class members for dependencies

Hi I am going back to C++ after spending some time in memory-managed languages, and I'm suddently kinda lost as to what is the best way to implement dependency injection. (I am completely sold to DI because I found it to be the simplest way to make test-driven design very easy). Now, browsing SO and google got me quite a number of opi...

How do we tell if a C++ application is launched as a Windows service?

We have a console app which we launch from command prompt for debugging, but we also launch this as an NT service for production. Right now, the code has this logic: if (__argc <= 1) { assumeService(); } else { assumeForgound(); } Is there a better way to check how the process has been launched? We're an open source project, so e...

Generate all of the unique combinations of numbers that add up to a certain number.

Hi Everyone, I am writing a program to try to solve a math problem. I need to generate a unique list of all of the numbers that add up to another number. For example, all of the unqiue combinations of 4 numbers that add up to 5 are: 5 0 0 0 4 1 0 0 3 2 0 0 3 1 1 0 2 2 1 0 2 1 1 1 This is easy to brute force in perl but I am workin...

Capturing window output in another window

I am building a C++ (Qt) based application for controlling a flash based UI. Because the flash runtime leaks spectatular amounts of memory, we execute the UI as a .swf loaded in the standalone flash player separate from the command-and-control app written i C++. The C++ starts the flash player as an external process with appropriate par...

Is there a open source library to help read Microsoft Compound Binary Files ?

Is there such a library? At at least a good documentation sorce as the one available by Microsoft is a bit hard to understantd and a bit superficial? Thanks ...