c++

Fetch-and-add using OpenMP atomic operations

I’m using OpenMP and need to use the fetch-and-add operation. However, OpenMP doesn’t provide an appropriate directive/call. I’d like to preserve maximum portability, hence I don’t want to rely on compiler intrinsics. Rather, I’m searching for a way to harness OpenMP’s atomic operations to implement this but I’ve hit a dead end. Can thi...

DialogBlocks on Windows: MSVCR80D.dll is missing

I build wxWidgets application with DialogBlocks on Windows 7 with VS2005 installed. Build is successful, but executable doesn't run giving the message: "The program can't start because MSVCR80D.dll is missing from your computer". The same code built in Visual Studio is OK. Build log: ----------------------- Configuration: VC++ Debug --...

Call methods on class templatized over enum

Given the following code: enum Fruits{ eApple, eBanana }; template<> struct SomeFruit< eApple > { void eatIt() { // eat an apple }; }; template<> struct SomeFruit< eBanana > { void eatIt() { // eat a banana }; }; Is there a way to call the explicitly specialized eatIt(), for each of Fruits, without having to make each call m...

What type should I use for an index variable.

This is a best practices question. I am making an array type * x = malloc(size*sizeof(type)); AFAIK sizeof gives a return value of size_t. Does that mean that I should use a size_t to declare, or pass around size? Also when indexing the array should I also use a size_t for the index variable? What is the best practice for these th...

Roman representation of integers

Possible Duplicate: How do you find a roman numeral equivalent of an integer I am looking for a simple algorithm (preferably in Python). How to translate a given integer number to a Roman number? string Roman(int Num){...} For example, Roman(1981) must produce "MCMLXXXI". ...

Advantages of an empty class in C++

What could be the possible advantages/uses of having an empty class? P.S: This question might sound trivial to some of you but it is just for learning purpose and has no practical significance. FYI googling didn't help. ...

Scanning Local Windows System for Attached USB Devices Using C++

What is the best way to scan the local Windows system for attached USB devices using C++? I need to get a list of Vendor and Product IDs to match against the my device's IDs. If there is a way to scan for a specific VID/PID combination, that would be even better. My end goal is to retrieve the virtual COM port Windows has assigned to ...

Linker error: undefined reference to `std::ctype<char>::_M_widen_init()

...

Programmatically detect if Windows Media Player is installed

Anybody have any advice on how to programmatically detect if Windows Media Player is installed? I know about the registry setting look up, but don't trust it since it's more than a little misleading (uninstalled may not remove it). And I've considered just launching a video, but an error could be caused by something other than Media Pl...

kdevelop no valid executable specified

hello, I've just installed kdevelop 4.1 , then created a normal hello world , build is ok but when i press execute it gives me (no valid executable specified) any idea ? ...

Win32 MVC pattern implementation

Hi, I'm currently working on a win32 application and I'm thinking I should probably use the MVC pattern. Now according to the pattern, the code that handles user interaction should be in the controller so that I can update the model and/or view accordingly. But in Win32, would that mean that my windowProc should be in the controller ? I...

How do I pass an Array (By Reference, in VB6) to a C\C++ *.dll subroutine?

I need to pass an empty Array of Variants to a DLL written in C (and available on all Windows versions), and the C code (which I have no control over and cannot edit) will populate the Empty Array of Variants with its some return values. Bascially, when I try this - the ByRef Array is always empty when it should contain the results of t...

Problem rendering characters with Freetype and OpenGL.

Hello Everyone, I've trying to develop a simple 2D game engine and I need to be able to draw text, so I decided to use the famous, freetype library. My current goal is to render every character from 0 to 255, and store the appropriate information in a glyph object, top and left positions of the character, width and height and an OpenGL ...

Size of a Packed Structure of Bools

If 1 bool is 1byte [8 bits] then would a packed structure of 4 bools be 32bits or 4? The pack directive removes the alignment requirement, but would it make sets of bools more efficient [memory wise]? ...

struggling with c++ IDE's on linux

hi I'm really frustrated, First I have no idea how to code the very complex (make files), so I'm using IDE's that would ease the job for me like (netbeans , eclipse ,Kdevelop .. etc) i almost tried every thing starting with Emacs (i'm very slow on it and I need autocompletion) Netbeans 6.9.1 (crashes , very slow editor,but amazing and...

Defaults constructors, why my class seems to have three? When compilers treats classes like structures?

I always thought, that there are only two defaults construcors: constructor with no arguments, and copy construtor. But today I wrote something like this: First I wanted to make sure that in C++ initialization of structures in c-style is still valid.. struct Foo{ int a; bool b; char* c; double d; }; //.. Foo arr[2]={{0...

Sources from subdirectories in Makefile

I have a C++ library built using a Makefile. Until recently, all the sources were in a single directory, and the Makefile did something like this SOURCES = $(wildcard *.cpp) which worked fine. Now I've added some sources that are in a subdirectory, say subdir. I know I can do this SOURCES = $(wildcard *.cpp) $(wildcard subdir/*.cpp) ...

C++ destructor code

Hi, I am have this simple C++ code, but I dont know how to use the destructor. class date { public: int day; date(int m) { day =m; } ~date(){ cout << "I wish you have entered the year \n" << day; } }; int main() { date ob2(12); ob2.~date(); cout << ob2.day; return 0; } the question i...

Question about the ostream operator <<.

Hi all. Let's say I make a class, like, which contains a char array. Now, what operator handles this: myClass inst; cout << inst; At the "cout << inst;" what is called, by simply the class' name? Thanks. ...

Private inheritance and swap

I'm using private inheritance in the implementation of two very related classes. The using Base::X; is very useful and elegant. However, I can't seem to find an elegant solution for reusing the base class's swap function. class A { public: iterator begin(); const_iterator begin() const; const_iterator cbegin() const; ...