c++

using spawnl and waiting for child process to exit

I am using c++ in borland development studio to launch a process. After the process is launched, the parent application is supposed to wait for it, but still keep processing windows messages. I tried using spawnl with P_WAIT after launching a timer, but timer wont fire when thread is blocked, i also tried using spawnl with P_NOWAIT toge...

Deciphering errors in upgrading a Visual C++ 6 project to Visual Studio 2008

I wanted to see if I could bring this defunct open source project called MouseTool up to date with Windows Vista. It's a dwell-clicker to help people (like myself) who experience pain when they click the mouse. This software simulates a click when the mouse pauses at a location on the screen. It seems like no one has touched this proje...

C++ pointer names

I understand pointers are used to point to objects so you would have to the same around in a program. But were and how are pointer names stored. Would it be an overkill to declare a pointer name that occupies more resource than the object it points to for example: int intOne = 0; int *this_pointer_is_pointing_towards_intOne = &intOne;...

Problems with setting up Function Pointers in Templated Class

I am trying to create a generic menu button class that is templated to a class, so I can make this button in any class. I want to create a void function pointer to different functions in that class, so when you click on the New Game button, it will call the NewGame() function etc. I'm still a little new to the idea of creating function...

Why is iplRotate() not giving me correct results?

sigh I'm sorry to say that I'm using Intel IPL (Image Processing Library) in some image processing code I'm working on. This is the tale of my struggle with getting my images to rotate correctly. I have a source image. It has a size (w, h) which is not necessarily square. It is going to be rotated by angle theta. I've calculated the ou...

Circular lock-free buffer

I'm in the process of designing a system which connects to one or more stream of data feeds and do some analysis on the data than trigger events based on the result. In a typical multi-threaded producer/consumer setup, i will have multiple producer threads putting data into a queue, and multiple consumer threads reading the data, and the...

What does "operator = must be a non-static member" mean? (C++)

I'm in the process of creating a double-linked list, and have overloaded the operator= to make on list equal another: template<class T> void operator=(const list<T>& lst) { clear(); copy(lst); return; } but I get this error when I try to compile: container_def.h(74) : error C2801: 'operator =' must be a non-static member ...

How do you transfer ownership of an element of boost::ptr_vector?

#include <boost/ptr_container/ptr_vector.hpp> #include <iostream> using namespace std; using namespace boost; struct A { ~A() { cout << "deleted " << (void*)this << endl; } }; int main() { ptr_vector<A> v; v.push_back(new A); A *temp = &v.front(); v.release(v.begin()); delete temp; return 0; } outputs: ...

What's a "Ch" in MSVC++?

I was thinking about my code, and I accidentally clicked the "Ln 74" at the botton of the MSVC++ window. I got a screen that said "Line number (1 - 136):", and it jumped the cursor to the line I entered. When I click the "Col 1" or "Ch 1" I get the same screen. I know Ln 74 means I'm on line 74, and Col 1 means I'm on column 1, but wh...

Need help understanding a C function

Here's the deal: I'm trying, as a learning experience, to convert a C program to C++. This program takes a text file and applies modifications to it according to user-inputted rules. Specifically, it applies sounds changes to a set of words, using rules formatted like "s1/s2/env". s1 represents the characters to be changed, s2 represents...

Visual Studio: how do I have the debugger stop when a member variable is modified?

I have program that has a variable that should never change. However, somehow, it is being changed. Is there a way to have the debugger stop when that particular member variable is modified? ...

is there a way to combine Qt-Creator + Boost Library?

Hi, I was wondering if there was a way to use the boost library in Qt-creator (the IDE version of Qt). Thanks, A. ...

Bjarne's new book - anyone done the exercises?

I'm doing the exercises in Stroustrup's new book "Programming Principles and Practice Using C++" and was wondering if anyone on SO has done them and is willing to share the knowledge? Specifically about the calculator that's developed in Chap 6 and 7. Eg the questions about adding the ! operator and sqrt(), pow() etc. I have done these b...

How would you make a header that does a file reading function in c++

This may sound newbie but, I am trying to make an external header that does a function that is reading from a file a name like joey and saving it as a variable to the other code it read from but i cant figure it out...It will be like this...One code will get this name and it will write it to the file...Then i want to use this header to r...

Cross-Platform way to get CPU/Memory utilization

Looking for a library or a fairly cross platform method to get CPU utilization, memory utilization, etc in C/C++. Something OTHER than getrusage(), I need for entire system, not one process. I've checked around, but haven't found much. I really need it on Linux, Mac Os X, and Windows, but if there's a solution for *nix systems (includ...

Odd/Incorrect Semaphore Behavior on OS X

Hi, I have some very basic semaphore code that works great on Linux, but cannot for the life of me get it to run properly on OS X... It returns the oddest of results... #include <iostream> #include <fcntl.h> #include <stdio.h> #include <semaphore.h> int main() { sem_t* test; test = sem_open("test", O_CREAT, 0, 1); int val...

Is it possible to create a "friend class" in C++?

I know it's possible to create a friend function in C++: class box { friend void add(int num); private: int contents; }; void add(int num) { box::contents = num; return; } But is there a way to create friend classes? NB: I know there are probably a lot of errors in this code, I don't use friend functions and am still pretty new to ...

Is it possible to declare a class without defining it? (C++)

I know the questions seems ambiguous, but I couldn't think of any other way to put it, but, Is it possible to do something like this: #include<iostream> class wsx; class wsx { public: wsx(); } wsx::wsx() { std::cout<<"WSX"; } ? ...

What do the Items on the properties tab of MSVC++ mean?

I was playing around with my MSVC++ compiler, and the properties tab for my point class said: IsAbstract - false IsInjected - false IsManaged - false IsSealed - false IsTemplate - false IsValue - false What do these mean, and why were all of them greyed out except IsAbstract and IsSealed? ...

construct two shared_ptr objects from the same pointer

hello, I have a problem from "The C++ Standard Library Extensions": Exercise 6 I said in Section 2.4.2 that you shouldn't construct two shared_ptr objects from the same pointer. The danger is that both shared_ptr objects or their progeny will eventually try to delete the resource, and that usually leads to trouble. In...