c++

overloaded "=" equality does not get called when making obj2 = obj1 ...

hello, i have this class called MemoryManager, it is supposed to implement a simple smart pointer, (count reference); i have a vector where i store the requested pointers,and i return the index of the pointer to the caller.. when a user creates a pointer of type MemoryManager he calls an initializer function called modified_malloc(s...

STL queue iteration

I need to iterate over a queue. www.cplusplus.com says: By default, if no container class is specified for a particular queue class, the standard container class template deque is used. So can I somehow get to the queue's underlying deque and iterate over it? Thanks. ...

webcam access in c++

I want to access the webcam so I can do some precessing on the images, like tracking a light, but I can't find a way to access the webcam. I googled it but I got confused. Can you point me to a library that can do that (windows)? and maybe also provide an example? I would need to periodically get a pixel map of the image, about 20 time...

Where do I put ATL dlls so they will work

A colleague developed a IE Plugin which I require to run for a piece of work using ATL. I have all of the source code and the compiled dll as well as a regedit. I have run the reg edit and moved the dll to the C:\Windows\System32 directory where I thought it was supposed to reside but that doesn't appear to have worked. Where should I ...

Is there a way to forward declare covariance?

Suppose I have these abstract classes Foo and Bar: class Foo; class Bar; class Foo { public: virtual Bar* bar() = 0; }; class Bar { public: virtual Foo* foo() = 0; }; Suppose further that I have the derived class ConcreteFoo and ConcreteBar. I want to covariantly refine the return type of the foo() and bar() methods like this: ...

Check if service is running?

I need to check if 'Event Log' services in running or not. How to do that? ...

How to move multi files using SHFILEOPSTRUCT?

How to move multi files using SHFILEOPSTRUCT? vector<CString> srcPaths; vector<CString> dstPaths; SHFILEOPSTRUCT FileOp;//定义SHFILEOPSTRUCT结构对象; int fromBufLength = MAX_PATH * imageVec.size() + 10; TCHAR *FromBuf = new TCHAR[fromBufLength]; TCHAR *ToBuf = new TCHAR[fromBufLength]; shared_array<TCHAR> arrayP...

How to fix weird camera rotation while moving camera with sdl, opengl in c++

I have a camera object that I have put together from reading on the net that handles moving forward and backward, strafe left and right and even look around with the mouse. But when I move in any direction plus try to look around it jumps all over the place, but when I don't move and look around its fine. I'm hoping someone can help me ...

forward declaration and template function error

Currently I have a frustrating problem with forward declaration and template function. I have been trying to googling and do some modification but nothing has worked so far. Below is the snippet of the code: class TaskScheduler; --> //forward declaration of ‘struct TaskScheduler’ // // class TaskEvent { // // }; class HostTask { // //...

In C++, when does a process retain allocated memory even though delete is called?

I would like to understand what is going on in the GCC runtime in the following situation. I have a C++ program that allocates many blocks of memory and then deletes them. What's puzzling is that the memory is not being returned to the OS by the GCC runtime. Instead, it is still being kept by my program, I assume in case I want to alloc...

Simple regular expressions questions

Hello. I have two simple questions about regular expressions. Having the string "$10/$50", I want to get the 50, which will always be at the end of the string. So I made: ([\d]*$) Having the string "50c/70c" I want to get the 70, which will always be at the end of the string(i want it without the c), so I made: ([\d]*)c$ Both seem do ...

What does zero-sized array allocation do/mean?

Looking at some example code and come across some zero-size array allocation. I created the following code snippet to clarify my question This is valid code: class T { }; int main(void) { T * ptr = new T[0]; return 0; } What is its use? Is ptr valid? Is this construct portable? ...

_beginthreadex static member function

How do I create a thread routine of a static member function class Blah { static void WINAPI Start(); }; // .. // ... // .... hThread = (HANDLE)_beginthreadex(NULL, 0, CBlah::Start, NULL, NULL, NULL); This gives me the following error: ***error C2664: '_beginthreadex' : cannot convert parameter 3 from 'void (void)' to 'unsigne...

Is there a difference between std::map<int, int> and std::map<const int, int>?

From what I understand, the key in a value pair in an std::map cannot be changed once inserted. Does this mean that creating a map with the key template argument as const has no effect? std::map<int, int> map1; std::map<const int, int> map2; ...

Casting between unrelated congruent classes.

Suppose I have two classes with identical members from two different libraries: namespace A { struct Point3D { float x,y,z; }; } namespace B { struct Point3D { float x,y,z; }; } When I try cross-casting, it worked: A::Point3D pa = {3,4,5}; B::Point3D* pb = (B::Point3D*)&pa; cout << pb->x << " " << pb->y << " " << pb-...

C++ byte stream

Hi Everyone, For a networked application, the way we have been transmitting dynamic data is through memcpying a struct into a (void*). This poses some problems, like when this is done to an std::string. Strings can be dynamic length, so how will the other side know when the string ends? An idea I had was to use something similiar to Java...

Building log4cxx on visual 2005

Hello, When I build the log4cxx on Visual 2005 according to instructions http://logging.apache.org/log4cxx/building/vstudio.html, I am getting error below; 1>------ Build started: Project: apr, Configuration: Debug Win32 ------ 1>Compiling... 1>userinfo.c 1>c:\program files\microsoft visual studio 8\vc\platformsdk\include\rpcndr.h(145)...

What is the most simple/elegant way to calculate the length of a number written as text ?

Given the maximum possible value, how to simply express the space needed to write such number in decimal form as text ? The real task: logging process ids (pid_t) with fixed length, using gcc on Linux. It'd be good to have a compile time expression to be used in the std::setw() iomanipulator. I have found that linux/threads.h header co...

How do I put an QImage with transparency onto the clipboard for another application to use?

I have a QImage that I would like to put on the clipboard, which I can do just fine. However the transparency is lost when that data is pasted into a non-Qt application. The transparent part just comes out as black. I tried saving the data as a transparent PNG but nothing is usable on the clipboard. This is what I have so far: QImag...

Why can I not initialize an array by passing a pointer to a function?

I know this has a really simple explanation, but I've been spoiled by not having to use pointers for a while. Why can't I do something like this in c++ int* b; foo(b); and initialize the array through... void Something::foo(int* a) { a = new int[4]; } after calling foo(b), b is still null. why is this? ...