c++

OpenGL Rotation Matrices And ArcBall

I have been tasked with creating a OpenGL scene implementing ideas such as simple movement, and an Arcball interface. The problem I am having is dealing with the rotation matrix which NeHe's Arcball class (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48) computes. What I have so far is a very simple solar system (just the ear...

GUI thread detecting in the Qt libary

I need to know in the context of which thread my function is running, is it main GUI thread or some worker thread. I can't use a simple solution to store QThread pointer in the main function and compare it to QThread::currentThread() because I'm writing a library and I do not have access to the main function. I can of course create Init...

Why does this derived class need to be declared as a friend?

I'm learning C++ on my own, and I thought a good way to get my hands dirty would be to convert some Java projects into C++, see where I fall down. So I'm working on a polymorphic list implementation. It works fine, except for one strange thing. The way I print a list is to have the EmptyList class return "null" (a string, not a pointer)...

exception problem with odbc and C++ causes bizarre database behavior

I have a C++ application (compiled with VS2003 running on windows 2000 server against SQL 2000 database) that ran fine for years and now is crashing. My logging shows that the database connection (ODBC using the SQL Server driver) will be working fine (read and update database) then after an exception throws (and is caught/logged but no...

OpenMp C++ algorithms for min, max, median, average

I was searching Google for a page offering some simple OpenMp algorithms. Probably there is an example to calculate min, max, median, average from a huge data array but I am not capable to find it. At least I would normally try to divide the array into one chunk for each core and do some boundary calculation afterwards to get the result...

Is there any kind of "expression class" (C++)

I am creating a game that lets the player enter input, changes some states, then checks if a "goal value" is true (obviously this description is muchly simplified), and I want to be able to have that goal value be anything from if the players life is below a certain value to if the amount of enemies remaining is equal to zero. Is there ...

Yield in C#

Does this have any equivalent in c? ...

C++ Boost ptr_map serialization error

I have some code that I want to build. The code uses boost::ptr_map class to serialize certain objects. I have Visual Studio 2008 with boost1.38 and I am getting following error from compiler. I wonder if any one else has seen any thing like this. C2039: 'serialize' : is not a member of 'boost::ptr_map' Looks like some reference is mis...

C# app to C++ dll back to the C# app via callbacks

Hi all, I'm writing a C# application that calls a C++ dll. This dll is a device driver for an imaging system; when the image is being acquired, a preview of the image is available from the library on a line-by-line basis. The C++ dll takes a callback to fill in the preview, and that callback consists basically of the size of the final...

recursive file search

I'm trying to figure out how to work this thing out .. For some reason, it ends at a certain point.. I'm not very good at recursion and I'm sure the problem lies somewhere there.. Also, even if I checked for cFileName != "..", it still shows up at the end, not sure why but the "." doesn't show up anymore.. void find_files( wstring wr...

Command pattern without virtual functions (C++)

For performance reasons, I am using the the Curiously Reoccuring Template Pattern to avoid virtual functions. I have lots of small commands which execute millions of times. I am trying to fit this into the Command Pattern. I want to add tons of commands to a queue, and then iterate through them executing each one by one. Each Command...

C++: Remove all HTML formatting from string?

Hi, I have a string which might include br or span.../span tags or other HTML characters/entities. I want a robust way of stripping all that and getting the remaining UTF-8 characters. This be should be cross-platform, ideally. Something like this would be ideal: http://snipplr.com/view/15261/python-decode-and-strip-html-entites-to-...

How to programatically cause a core dump in C/C++

I would like to force a core dump at a specific location in my C++ application. I know I can do it by doing something like: int * crash = NULL; *crash = 1; But I would like to know if there is a cleaner way? I am using Linux by the way. ...

C++ / CLI - Change all files to UNMANAGED by default

Does anyone know how to change the default behavior of the /clr switch to make all files unmanaged by default? The default behavior of the switch is to make all files managed. I know I can mark each .cpp file individually, but there are ALOT of them... ...

Does an STL map always give the same ordering when iterating from begin() to end()?

It appears to from my simple testing but I'm wondering if this is guaranteed? Are there conditions where the ordering will be not be guaranteed? Edit: The case I'm particularly interested in is if I populate a map with a large number of entries, will the order of the itertator be the same across multiple runs of my executable? What if ...

learning c++ from boost library source code

I am very interested in c++ and want to master this language. I have read a lot of books about c++. I want to read some library source code to improve my skill, but when I read the boost library source code, I find it is very difficulty. Can anyone give me some advice about how to read boost source code and before I can understand it w...

Struct inheritance in c++

can struct be inherited in C++ ? ...

What are the benefits are programming in C over C++

Possible Duplicates: C over C++ Why would anybody use C over C++? What’s the advantage of using C over C++ or is there one? I have seen some open source projects that are done in C and I am curious to know if there is something to be gained using C or if it is just a personal preference. ...

What's wrong with my random number generator?

I'm just diving into some C++ and I decided to make a random number generator (how random the number is, it really doesn't matter). Most of the code is copied off then net but my newbie eyes cannot see anything wrong with this, is there any way this can be tweaked to give a number other than "6" each time? #include <iostream> #include <...

Help with c++ template templates.

Ok, so I wrote an stl-like algorithm called cartesian_product. For those who don't know, the cartesian product is every possible pair of elements from two sets. So the cartesian product of {1, 2, 3} and {10, 20, 30} is {(1,10), (1,20), (1,30), (2,10), (2,20), (2,30), (3,10), (3,20), (3,30)} So the function looks like template <typenam...