c++

Do I include how to use the GPL in COPYING?

I'm coding a program and I have the entire GPLv3 license from http://www.gnu.org/licenses/gpl-3.0.txt in a COPYING text file. However, at the end, there's a section on 'How to Apply These Terms to Your New Programs'. Do I keep this in COPYING? Is it part of the GPLv3 or a reminder on how to use it? ...

C++ composition with iterator

Hi, I'll try and keep my sample code very straightforward, but it may have errors as I'm typing it on the spot. I have a class named Phone. class Phone { public: Phone(std::string manufacturer, std::string model, std::vector<Feature> features); private: std::vector<Features> features; std::string model; std::string manufactu...

Omni light in OpenGL?

I want to basically create a light that will make it so that its very bright around the player then gets progressively darker. Sort of like a fire torch. How can I get this effect? I can only seem to get an ambient light? How can it follow the camera? Thanks ...

Cannot implement meter in windows API

I am using the windows API (in C++) to create a windows application. Now, I have a progress bar which I want to show like a meter. A meter is blue and has no animation. I cannot figure out how to implement this, and if I have to, I will just settle for the usual green progress bar. Please help. EDIT: At least, is it possible to disabl...

C++ SetConsoleCtrlHandler routine issue

I'm writting a console application in C++. I use SetConsoleCtrlHandler to trap close and CTRL+C button. This allows for all my threads to stop and exit properly. One of the thread performs some saving that require some time to complete and I have some code to wait in the console crtl handle routine. MSDN specify that a box should pop u...

std::sort and std::unique problem with a struct

The following code: #include <vector> #include <algorithm> struct myStructDim { int nId; int dwHeight; int dwWidth; }; void main() { ::std::vector<myStructDim> m_vec_dim; ::std::sort(m_vec_dim.begin(), m_vec_dim.end()); m_vec_dim.erase( ::std::unique(m_vec_dim.begin(), m_vec_dim.end())...

Setting a memory limit on my AI algorithm?

I am working on a Tetris AI implementation. It is a GUI application that plays the game by itself. The user can manipulate a few parameters that influence the decisions made by the AI. The basic algorithm goes as follows: Start a new thread and clone the current game state to avoid excessive locking. Generate a list of all possible fut...

MinGW Compilation Problem

Hi, I just installed MinGW using the automatic installer MinGW-get-inst that I found on their website. I am using eclipse to write my C++ programs. My code compiles fine, and I get a .exe file. However, when I try to open this executable, I get the error that libgcc_s_dw2-1.dll is missing from my computer. I have located this file under...

C++ game trainer process monitoring

I am going to open game process from my trainer app and write some values to memory. I have no problems with opening a process and writing a value to memory. But I can't realize how to monitor the game process availability. For example I opened a running process, user closed it and opened again. How can I track this in my code? OpenProce...

how can I check if an object exists in C++

I am trying to write a function that will check if an object exists: bool UnloadingBay::isEmpty() { bool isEmpty = true; if(this->unloadingShip != NULL) { isEmpty = false; } return isEmpty; } I am pretty new to C++ and not sure if my Java background is confusing something, but the compiler gives an error: Unlo...

Difference between file.is_open() and file.fail()

Initialization of file: ifstream file("filename.txt"); What's is the difference between if ( file.is_open() ) and if (! file.fail() ) ? What Should I use to make sure if the file is ready for I/O ? We assume that variable file contains a object of a file stream. ...

Dynamic Data Slicing tools for Java and C++

I am looking for dynamic data slicing tools for Java and C++ that can detect both data and control dependencies in the program. I found out JSlice for Java and none for C/C++. Are there any other dynamic data slicing tools available for Java/C++/C ? ...

Is there any cleaner way to do this? (Prepared SQL queries in Qt C++)

I'm using QSqlQuery::prepare() and ::addBindValue() for my queries in a Qt project I'm working on. There's a lot of repeated code and though I think that's the "right" way, I wanted to make sure. Perhaps someone has alternative ideas? Example: QSqlQuery newQuery; newQuery.prepare("INSERT INTO table " "(foo,bar,baz," ...

A Question regarding C++ exceptions

If you check this link http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=107 it's written: "For example, the abort() and exit() library functions are never to be used in an object-oriented environment—even during debugging—because they don't invoke objects' destructors before program termination." Why does the dest...

list iterator problem in c++?

#include <iostream> #include <list> #include <string> using namespace std; // Simple example uses type int main() { list<string > L; L.push_back("test"); // Insert a new element at the end L.push_back("testinggggg"); L.push_back("example"); list<string>::iterator i; for(i=L.begin(); i != L.end(); ++i) { ...

SDL/C++/OpenGL graphics display says "Not Responding" on cin from console.

So the story goes, I have an sdl/c++/opengl/win32 program which has a window to display my graphics and a console to get user input. When I tell the console to get input the display will go into a "Not Responding" mode. The program is single threaded and I was hoping that there was a better way around the problem then creating a multi-...

Why is Builder pattern better than a Constructor with arguments in the Class's object being created?

Why can we not the different build steps within the constructor itself. if the build steps take arguments why can't they be provided as arguments to constructor and utilized within constructor to create the object. AFAIK, in Builder pattern, the client which specific object to create; then what is the advantage in using a builder instea...

What Qt widgets to use to draw a "game-of-life"-like application ?

For an experiment, I'd like to create a simple graphical application. My goal isn't complex: I just need to draw single pixels or lines of different colors, and refresh the view regularly. Something like Conway's Game of Life. I'm used to work with Qt but never for this kind of task. What widgets/objects should I use to get started ? ...

address of c++ template function

Why does this fail to compile? (g++-4.5) template < typename U > static void h () { } int main () { auto p = &h<int>; // error: p has incomplete type } EDIT: Here is a work-around: template < typename U > static void h () { } int main () { typedef decltype (&h<int>) D; D p = &h<int>; // works } ...

C++ re-throw an exception caught by ...

Hi, how can I re-throw an exception caught by catch(...) block? ...