Here is the example code:
#include <iostream>
#include <list>
#include <tbb/task.h>
#include <tbb/task_group.h>
#include <stdlib.h>
#include <boost/thread.hpp>
using namespace tbb;
long fib(long a)
{
if (a < 2) return 1;
return fib(a - 1) + fib(a - 2);
}
class PrintTask
{
public:
void operator()()
{
std::cout <...
I am coding a c++ project with Qt Creator. Everything is working fine (debug, release), but when I run the compiled .exe directly (go to exe file and run it) it says mingwm10.dll is missing.
What can I do about this problem?
...
In my MFC dialog, i have a tree view control with checkboxes. Clicking the checkbox does not raise the NM_CLICK nor the TVN_SELCHANGED events, which I had hoped it would do.
How do I correctly determine when a checkbox is checked/unchecked in a tree view control?
...
Note: This may sound dumb.
I have an application which uses raw pointers and there are lots of memory leaks in the application.
Now my question is how easy would it be to replace the existing raw pointers with the smart pointers.
And would just replacing them help is reducing memory leaks caused by not freeing dynamically allocated mem...
This question is perhaps somehow odd, but how can I speed up g++ compile time? My C++ code heavily uses boost and templates. I already moved as much as possible out of the headers files and use the -j option, but still it takes quite a while to compile (and link).
Are there any tools out there which analyse my code and point out bottle-...
Possible Duplicate:
C++ Prime number task from the book
Asked the question already but haven't gotten satisfiable answers;
So can someone clear the following code on the level beginner could understand [I'm a beginner], it's from the book C++ From The Ground Up 3rd edition by Herbert Schildt
int i, j;
for(i=2; i<16; i++) ...
I have a library for which I have created a python wrapper using SWIG. The library itself accepts user provided functions which are in an .so file that is dynamically linked. At the moment I'm dealing with one that I have created myself and have managed to get the dynamic linking working... in C++. When I attempt to run it in python I ge...
Hi,
This is similar to one of my other questions, but different enough I think to warrant a new question.
Basically I am writing a user interface, and my user interface has nodes that can be selected. When a node is selected, the user interface ends up with an abstract node base class "INode". From this I get a factory by doing node->...
hey folks, why does this:
char** pointer = new char*[1];
std::cout << sizeof(pointer) << "\n";
output 4? I have an array of pointers, but it should have length 1, shouldn't it?
...
I am trying to pass back a string from a Java method called from C++. I am not able to find out what JNI function should I call to access the method and be returned a jstring value.
My code follows:
C++ part
main() {
jclass cls;
jmethodID mid;
jstring rv;
/** ... omitted code ... */
cls = env->FindClass("ClassifierW...
I am trying to create a function in VC++ that takes a function pointer but I keep getting syntax errors.
The declaration in my header file looks like this:
void ApplyFuncToCellsInSelection(void(*func)(CPoint, *CSpreadWnd));
Here is the definition:
void CSpreadWnd::ApplyFuncToCellsInSelection(void(*func)(CPoint, *CSpreadWnd)) { ... ...
I tried to use copy constructor using statement:
X y = X();
But copy constructor is not being called. I am using g++ 4.1.0. I set both X(const X&) and X(x&) constructor in the class.
Is this supposed to work or I am doing some very basic problem in the code?
My code for the class is
class A
{
public:
int i;
A(int ii)
{
...
I have a windows service, that makes several COM+ calls during initialization. On some systems this windows service causes a deadlock during startup.
At least one service or driver failed during system startup
The problem with calling CoCreateInstance during service startup is that it might require other services to startup. And th...
Dear reader,
I'm working on an application where I draw a circular progress indicator which slowly gets "filled", here you can see a couple of images. I'm using intermediate mode and I'm only drawing this circular shape by drawing the vertices at each frame update (see code below). When the circle fills up the border line between the wh...
Consider the following ways of declaring and initializing a variable of type C:
C c1;
C c2;
c2 = C();
C c3(C());
C c4 = C();
Are all of these completely equivalent to each other, or can some of these differ depending on the exact definition of C? (assuming it has public default and copy constructors).
...
Hello,
I want to make program that encrypts (later decrypts) user inputted string.
Here is beginning for encryption:
QString getData = ui->text->toPlainText(); //Data to process
std::string output; //Result will be Base32 encoded string, so std::string is fine.
Now, I have to convert QString to char* or std::string so it can be accept...
I want my exception handlers and debug functions to be able to print call stack backtraces, basically just like the backtrace() library function in glibc. Unfortunately, my C library (Newlib) doesn't provide such a call.
I've got something like this:
#include <unwind.h
printf("\t#%d: program counter at %08x\n", *depth, _Unwind_Get...
Hi, as I've asked in here and after a while I've agreed and accepted right answer to that question I was just thinking, if would it be useful to have something like "moving destructor" which would be invoked on moved object everytime we used move ctor or operator=.
In this way we would have to specify only in move dtor what we want from...
I have an a simple Registry pattern:
class Object
{
//some secondary simple methods
};
#define OBJECT_DEF(Name) \
public: \
static const char* Name() { return Name; } \
private:
class Registry
{
struct string_less {
bool operator() (const std::string& str1, const std::string& str2) {
for(int i = 0; i < str1.size() && i < st...
I have a set of data which is split into two arrays (let's call them data and keys). That is, for any given item with an index i, I can access the data for that item with data[i] and the key for that item with keys[i]. I cannot change this structure (eg, to interleave keys and data into a single array), because I need to pass the data ar...