c++

Linux vs Windows Programming?

I've spent the last 5 years developing software with Windows as the target OS (mainly C++ and C#). Recently I started to become interested in development for other environments as well, Linux for example. So I guess I actually have two questions. The first is: Do you find developing software for Linux harder than developing for Windows?...

Linux Reference for C++?

I want to know if there is any site like cpluplus.com which explains all the headers files and its available features, but for Linux ? Like for example explaining the sys/, net/, dns/* includes ? I came up with this question because I was searching for a sys/reboot.h reference. Any Ideas ? ...

Paste text to active window linux

I want to write application which paste some text to active window on some keystroke. How can i do this with Python or C++ ? Update: Sorry people. I think i don't describe problem clearly. I want to write app, which will work like a daemon and on some global keystroke paste some text to current active application (text editor, browser,...

Defragmenting C++ Heap Allocator & STL

I'm looking to write a self defragmenting memory manager whereby a simple incrementing heap allocator is used in combination with a simple compacting defragmenter. The rough scheme would be to allocate blocks starting at the lowest memory address going upwards and keeping book-keeping information starting at the highest memory address...

Imposing constrains of template function types, without c++0x concepts

Now that we know that Concepts is not part of C++0x, I am looking for methods to impose restrictions on types in template functions. Here are two examples: If we want to make sure that a given type is an integer, we can use: template <class N> inline int f(const N n) { if ((N)0.1 != 0) // if type of N is floating-poi...

C++ Templates Error

I'm trying to write a simple vector class with templates, but when I split it into a .h and a .cpp file, I get these errors: undefined reference to vector<int>::vector()' undefined reference to vector::add(int)' undefined reference to vector<int>::add(int)' undefined reference to vector::remove(int)' the code: http://pastie.org/623584 ...

C++ Member Function Pointers and STL Algorithm Problem

Okay I have a bit of a problem which i'm struggling to solve. Basically I have an abstract functor class that overloads operator() and derived objects that implement it. I have a function (part of another class) that tries to take an Array of these functor classes and tries to pass a pointer to a member function to the std algorithm fo...

C++ libraries for Image Segmentation

Hi, I am going to do a project in Data Mining related to image clustering (in C++) .I am looking for a powerful library which is helpful in image processing, linear algebra and 3d graphics. Any thoughts? Thanks. ...

Python generators in various languages

How do you emulate Python style generators in your favorite language? I found this one in Scheme. It must be interesting to see other implementations, especially in those languages that don't have first-class continuations. ...

C++ Templates and Inheritance

Let's say I have a simple Server with a template which accepts a Client as it's template argument: template<class T> class Server<T>{ Server(int port); } and a Client is defined something like this: class Client{ Client(Server<Client> *server, // <-- int socket); }; But I also want say, have the class User inheri...

Member variables and STL algorithms

#include <vector> #include <functional> #include <algorithm> using namespace std; struct Foo { int i; double d; Foo(int i, double d) : i(i), d(d) {} int getI() const { return i; } }; int main() { vector<Foo> v; v.push_back(Foo(1, 2.0)); v.push_back(Foo(5, 3.0)); vector<int> is; ...

Programably make and play a sound through speakers C++

I'm making a game in native vc++ (not .Net) I'm looking for a way to play a noise (maybe 8 bit or something) through the real speakers (not internal). I know about PlaySound, but I don't want to make my EXE big. I want to program the sound. Is there an api way (kinda like Beep() ) but that plays through the real speakers? Thanks ...

Is there a way to diff files from C++?

I'm looking for a C or C++ diff library. I know I can use the Unix diff tool in combination with system or exec, but I really want a library. It would be handy if the library could perform patches as well, like the Unix patch tool. ...

calculate array index from pointers

Me and some peers are working on a game (Rigs ofRods) and are trying to integrate OpenCL for physics calculation. At the same time we are trying to do some much needed cleanup of our data structures. I guess I should say we are trying to cleanup our data structures and be mindful of OpenCL requirements. One of the problems with using op...

Fast exponentiation: real^real (C++ MinGW, Code::Blocks)

I am writing an application where in a certain block I need to exponentiate reals around 3*500*500 times. When I use the exp(y*log(x)) algorithm, the program noticeably lags. It is significantly faster if I use another algorithm based on playing with data types, but that algorithm isn't very precise, although provides decent results for ...

Creating an array of zero width and zero height!?

I have an assignment from my programming class, which is very poorly worded... The following line really stumps me. We're creating a class called FloatArray, which contains an array (arr, which is just a pointer to a bunch of floats). The default constructor FloatArray(); should create array of zero width and zero height. I have ...

Static lib that links another static lib and qmake? Odd linking error

I have two qt .pro files, both using the lib TEMPLATE and staticlib CONFIG. The first library (lets call it 'core') is a dependency for the second lib (I'll call it 'foo'). In fact, there's a class in foo that extends a class in core, I will call this class Bar. When I instantiate the class (which is defined and implemented in foo, but ...

Good books or tutorials for beginning Direct X with c++

I'm pretty familiarity with c++. I'v made a few games like tetris and solitaire with it. But what I would really like is some nice textured graphics for those games :-p GDI just isn't doing it for me anymore. Really, all I would need to know is: DX scene initialization making something simple like a round rectangle and basic shapes ab...

How to read an intermittent hard drive consistently?

I have a faulty hard drive that works intermittently. After cold booting, I can access it for about 30-60 seconds, then the hard drive fails. I'm willing to write a software to backup this drive to a new and bigger disk. I can develop it under GNU/Linux or Windows, I don't care. The problem is: I can only access the disk for some time, ...

Count up and down elegantly

I'm trying to make a flashing object, i.e., increment it's alpha value from 0 to 255 (gradually) and then back down to 0, and repeat. Is there a way I can do this without using some boolean? Getting it to increment is easy: alpha = time.elapsed()%256; But what's a nice way to get it to count back down again after that? ...