c++

Using OpenGL /GLUT how would I detect if two keys are held down at the same time?

Using OpenGL /GLUT how would I detect if two keys, say 'a' and 'j' are held down at the same time? (This program needs to compile with OSX GCC, Windows GCC, Windows VS2005 so no OS dependent hacks please.) ...

Memory allocation in VC++

I am working with VC++ 2005 I have overloaded the new and delete operators. All is fine. My question is related to some of the magic VC++ is adding to the memory allocation. When I use the C++ call: data = new _T [size]; The return (for example) from the global memory allocation is 071f2ea0 but data is set to 071f2ea4 When overlo...

Precompiled headers supported on gcc 3.3.3 ?

Are precompiled headers supported on gcc 3.3.3 ? If yes what is the syntax to generate and use precompiled headers on Linux with gcc 3.3.3. We crosscompile our projects on Windows and Linux, on Windows we precompile stdafx.h and I'm investigating how to set it up so that it is precompiled on Linux as well. I'm aware of the gcc doc , I'...

Memory Efficient Methods To Find Unique Strings

I have a data set that looks like this: 000 100 200 300 010 020 030 001 002 003 001 101 201 301 011 021 031 000 002 003 002 102 202 302 012 022 032 001 000 003 003 103 203 303 013 023 033 001 002 000 010 110 210 310 000 020 030 011 012 013 020 120 220 320 010 000 030 021 022 023 030 130 230 330 010 020 000 031...

Monitoring storage space on windows mobile

In a native(c++) windows mobile app. There are ways to be notified of low memory, WM_HIBERNATE, and low power, RequestPowerNotifications(). Is there any way to be notified when storage space is running low? Or must an app just poll regularly with GetDiskFreeSpaceEx()? ...

What does this code in "vector" mean? (C++)

I created a program, and it uses the vector.h #include, and iterators, etc... But when I run the program, under certain circumstances (I'm still trying to figure out what those would be) I get an assertion error refering me to line 98 of vector.h. I went to line 98 of vector.h and got this: #if _HAS_ITERATOR_DEBUGGING if (this->_...

Qt: how to set main window's initial position?

I think the normally window manager determines the initial position of the QMainWindow position on the desk top. I want to set the initial position myself. How is this done with Qt on Windows? ...

How to find the difference between two times in c?

Hi my first time is 12:10:20 PM and second time is 7:10:20 Am of the same day how can i find diff b/w them?? My idea is convert all the time to seconds and find the difference again convert to time is it good Approch r anything else?? ...

Best way to send array of key-value pairs to an API in COM

I want to create an interface with API that can accept array of key-value pairs in COM. What is the best way to do that? I can think of sending SAFEARRAY of BSTR .Each BSTR can be considered as key-value pair . Logic of packing /unpacking key-values need to be added. ...

Passing a **Class as an argument

Hi, I'm trying to declare a method in main.h like this: void buildGraph(int gNum, Graph** gArray); Where Graph is a class and I'm trying to pass a pointer to an array of pointers to Graph objects. I get the error message: "Graph has not been declared". Even though I have #include "graph.h" at the top of the page and I've been using ...

Is there a way to use C++ for iPhone development?

Sorry if this is mentioned somewhere, couldn't find any info about it. Post a comment if you find a duplicate. This is not about whether it's possible at all to compile a C++ program for the iPhone (which I suppose is possible). Basically the question is, can you bridge between Objective C and C++?, and if it is possible, would it be f...

C++ implicit conversions

Several comments on a recent answer of mine, http://stackoverflow.com/questions/862858/what-other-useful-casts-can-be-used-in-c/862896#862896, suggest that my understanding of C++ conversions is faulty. Just to clarify the issue, consider the following code: #include <string> struct A { A( const std::string & s ) {} }; void func( ...

MSHTML IWebBrowser2 problem - Sinking page events causes missed keystrokes??

Hi all, I've got a bit of a problem with my application using MSHTML. I have everything working except for the odd keystroke missing behavior when typing fast as mentioned in the subject line. I think it may have to do with the method I use to sink the events? The details: my application is a separate program written in C++ and MFC in V...

quickest way to generate random bits

What would be the fastest way to generate a large number of (pseudo-)random bits. Each bit must be independent and be zero or one with equal probability. I could obviously do some variation on randbit=rand()%2; but I feel like there should be a faster way, generating several random bits from each call to the random number generato...

How to modify the tool rect of a CToolTipCtrl?

This question is related to this one. In a CDockablePane derived class I have a CTreeCtrl member for which I add a ToolTip in OnCreate(): int CMyPane::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDockablePane::OnCreate(lpCreateStruct) == -1) return -1; const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | W...

How do I plot the output from a C++ Win32 console app?

I have a small Win32 console application which is essentially a test harness. I read data in, do some processing on it and currently just output some of the numbers to the console. This isn't a huge problem - I can get an idea of what the data looks like, but it would be much easier to analyse if there was a way of getting that informati...

Where can I find a feed Library for C++/MFC?

I am looking for a C++ feed library. Where can I find one? Edit: I need to be able to access feeds from my MFC application. I would like to have a library that can deal with RSS, audio, video, and whatever else it can fit. ...

Polymorphic or generic approach is better? C#

I have two classes and an interface like interface IVehicle { void Drive(); } class Benz :IVehicle { public void Drive() { Console.WriteLine("WOW! driving benz"); } } class Ferrari : IVehicle { public void Drive() { Console.WriteLine("WOW! driving ferrari"); } } I got a Driver class which ...

What is the difference between static_cast and Implicit_cast?

What is implicit_cast? when should I prefer implicit_cast rather than static_cast? ...

Reading binary file defined by a struct

Hi, Could somebody point me in the right direction of how I could read a binary file that is defined by a C struct? It has a few #define inside of the struct, which makes me thing that it will complicate things. The structure looks something like this: (although its larger and more complicated than this) struct Format { unsigned lon...