c++

How to make C++ code draw on Java components

We are designing physics app, and we would like to have it written in Java, and also we want to use root (root is writen in C++). Root has some nice graphical features -- it is able to draw very nice 3D charts, and I'm thinking whether it's possible to embedd those charts in Java app. Is there any way to make C++ code draw on for examp...

Stream Insertion Operator overloading

Im really unsure how to call the function: friend ostream& operator<<(ostream& out, stack::myItem& theItem); that is public to my stack object: class stack { public: stack(int capacity); ~stack(void); void method1(); ... private: struct myItem { int item; }; ... public: f...

Learning to create animations in C++

does anyone know where I can learn to create and manipulate animations in c++ for the purpose of game development? ...

How to build in release mode with optimizations in GCC?

Hello, What are the specific options I would need to build in "release mode" with full optimizations in GCC? If there are more than one option, please list them all. Thanks. ...

How to divide two doubles accurately

I have two double a, b; I know that the following is true -1 <= a/b <= 1 however b can be arbitrarily small. When I do this naively and just compute the value a/b the condition specified above does not hold in some cases and I get values like much greater than 1 in absolute value (like 13 or 14.) How can I ensure that when ...

code blocks 8.02 console program not outputting cout statements with SDL

im currently using the SDL-devel-1.2.13-mingw32 library in code blocks 8.02. with the mingw 5.1.6 installed separately on C:\ this program compiles and runs with no errors but i can't see the last system("pause"); on the screen. When i press any key, it of course skips over the system("pause"); then code blocks tells me that it successfu...

Memory leak caused by a wrong usage of scoped_lock ?

I have a memory leak, and I guess it's caused by a wrong usage of scoped_lock (Boost). I however don't manage to find the exact problem, and I do believe that the way the code has been written is not completely right neither. The code is in this class there: http://taf.codeplex.com/SourceControl/changeset/view/31767#511225 The main imp...

C++ Read File Into hash_map

I'm trying to read in a list of words and save them in a C++ STL hash_map along with their position in the alphabetically sorted file. The idea is later I'll need to be able to tell if a string is a word and whether it comes before or after a different word. ifstream f_dict ("dictionary.txt"); __gnu_cxx::hash_map <const char*, int> dic...

Resource for learning Lua to use with C++?

So I have heard that Lua is a good scripting language that ties into C++. Does anyone know some good resources for picking it up, for someone with lots of C++ experience? ...

Google Geolocation API library

Hey all, Is there a library out there that will get you your approximate location using the google service (https://www.google.com/loc/json)? Google Gears has support for it as described here http://code.google.com/p/gears/wiki/GeolocationAPI There is also good doco on the web service request/response schema. Firefox and iPhone Safari...

C++ partial method specialization

Is there a partial specialization for template class method? template <class A, class B> class C { void foo(); } it doesn't work to specialize it like this: template <class A> void C<A, CObject>::foo() {}; Any help? ...

C++ change newline from CR+LF to LF

I am writing code that runs in Windows and outputs a text file that later becomes the input to a program in Linux. This program behaves incorrectly when given files that have newlines that are CR+LF rather than just LF. I know that I can use tools like dos2unix, but I'd like to skip the extra step. Is it possible to get a C++ program i...

Swapping Nodes on a single linked list

Trying to make a swapNode function that can take any two nodes and swap them. I've made an algorithm that works if they're at least 2 nodes away, but I can't seem to come up with an algorithm that will work if they are closer to each other. Here's what I wrote so far: void swapNode(call * &head, call * &first, call * &second){ call...

Touch friendly GUI in Windows Mobile

I'm porting an audio processing application written in C++ from Windows to Windows Mobile (version 5+). Basically what I need to port is the GUI. The application is quite complicated and the GUI will need to be able to offer a lot of functionality. I would like to create a touch friendly user interface that also looks good. Which basical...

Does C# have an equivalent to #pragma pack in C++?

C# provides StructLayoutAttribute.Pack, but its behaviour is "every member gets at least the specified alignment whether it wants it or not", whereas the behaviour of #pragma pack in C++ is "every member gets the alignment it wants, unless it wants more than the specified alignment, in which case it's not guaranteed to get more than that...

Drawing a complex function with GNU Plot

Hello, I am working in a research laboratory and my tutor asked me to draw the langerman statistic function with GNUPlot. Hi gave me this code, that should be able to generate the cordinate. #include "stdafx.h" #include "fitness.h" #include "function.h" double temp1(double d1, double d0); double temp2(double d0); //double RozenBrock(d...

Converting a Windows Dll to .lib for C++ Visual Studio 2008

I know there is a tool called Dll to lib but the developer is asking $1000. I only need to convert one library, once, so its not easy to justify that price. I tried IMPLIB32.EXE, but I just get empty .lib files. How can I accomplish this? Perhaps I can write a simple conversion app? Added1: The Dll's are typically stdcall not cdecl an...

ValidateUser instead of LogonUser?

We're trying to "lock down" a computer such that we have a generic login account for Windows XP that has very few permissions. Our software is then launched via a launcher that runs it as more privileged user, allowing it to access the file system. Then, an operator will login to our software and we were hoping to authenticate their cr...

Does std::vector.pop_back() change vector's capacity?

If I allocated an std::vector to a certain size and capacity using resize() and reserve() at the beginning of my program, is it possible that pop_back() may "break" the reserved capacity and cause reallocations? ...

List processes for specific user...

Hello, Would someone be able to point me to the C++ API's that I can use to display a list of processes and the user name in Windows? My current code uses the CreateToolhelp32Snapshot Function which shows all the processes running for all users, but I do not know what API's to use to retreieve the user name so I can filter it by user. ...