c++

Why does my debugger sometimes freak out and do things like not line up with my code?

When I'm using my debugger (in my particular case, it was QT Creator together with GDB that inspired this) on my C++ code, sometimes even after calling make clean followed by make the debugger seems to freak out. Sometimes it will seem to be lined up with another piece of code's line numbers, and will jump around. Sometimes this is is o...

Using <urlmon.h> and URLDownloadToFile to get HTTPS Web Resources

All, I am making a programming that will be able to download content from various websites on and off of my local network.To do this, I must use the libs and c++ for compatibility reasons. So far I have been able to successfully access a normal HTTP page, and an HTTPS page on the web. Example: HRESULT res = URLDownloadToFile( NULL, ...

Upcasting instance and Invoking a function on base class in C++

class PureVirtual { public: virtual PureVirtual& Foo () = 0; virtual ~PureVirtual () {} }; class SemiVirtual : public PureVirtual { public: PureVirtual& Foo () { printf ("foo worked."); return *this; } virtual ~SemiVirtual () {} }; class NonVirtual : public SemiVirtual { public: NonVirtual& Bar () { printf ("bar worked....

Advice for dealing with code maintenance

Hi guys, I've been working at my university this summer in an image/video lab. Just recently, my professor gave me a program written by a grad student who just left the program to "fix up", because it was "giving some errors." The project was written in C++ (seems to be a recurring bad sign in student code). I opened the project in VS0...

C++ Replace part of a string with another string

Is it possible in C++ to replace part of a string with another string. Basically, I would like to do this QString string("hello $name"); string.replace("$name", "Somename"); but I would like to use the Standard C++ libraries. ...

OpenGL Texture Mapping Error

Here's a BIG problem with my project: I love the tutorials on the NeHe website, and Windows XP ran the programs perfectly. However, when I reformatted my computer, changed the OS to Windows Vista and reinstalled my Dev-C++ compiler, and then I tried to open any C++ program that used textures, the program crashed. I realised my glaux.h ...

QT: help with QGraphicsView, QGraphicsScene, QGraphicsItem positioning

Hello, I am trying to use the QGraphicsview, but I have lot of trouble with it. My goal is very simple (for the moment): I want to create a basic pianokeyboard component, where you can set the number of keys, and where the keys automatically stretch when you resize the keyboard. I am a newbie in QT, so maybe I am wrong in the design t...

I want to learn C# and C++ and other such langurages...What is the best way?

Possible Duplicate: How to Learn Python I have recently started a new job and knowing a few more programming languages would be VERY helpful! any ideas where/how to learn C#, C++, perl, python, etc... as quick as possible? ...

Buffer underrun logic problem, threading tutorial?

Ok, I tried all sorts of titles and they all failed (so if someone come up with a better title, feel free to edit it :P) I have the following problem: I am using a API to access hardware, that I don't coded, to add libraries to that API I need to inherit from the API interface, and the API do everything. I put in that API, a music gene...

Decode wav file into raw on win32

How can I decode a wav file (RIFF) containing PCM data on Windows into raw samples (so that I can feed it to ASIO) on win32? I don't have time to reinvent the wheel. If there's a library out there that does the whole "play a wav file into ASIO" thing at once, that would be nice. ASIO is simple enough, though, and has many examples for...

How to idiomatically call C++ functions based on variable value?

Suppose I have a data type enum TreeTypes { TallTree, ShortTree, MediumTree }. And I have to initialize some data based on one particular tree type. Currently I have written this code: int initialize(enum TreeTypes tree_type) { if (tree_type == TallTree) { init_tall_tree(); } else if (tree_type == ShortTree) { ...

union consisting of float : completely insane output

#include <stdio.h> union NumericType { float value; int intvalue; }Values; int main() { Values.value = 1094795585.00; printf("%f \n",Values.value); return 0; } This program outputs as : 1094795648.000000 Can anybody explain Why is this happening? Why did the value of the float Values.value increase? Or am I m...

Is it possible to remove the preview widget from a qt QColumnView?

Hi, I need to display a hierarchical set of data in a qt view. I'm using QColumnView to display the model. However, there is a feature such that the last column in the view will be relegated to a preview widget. Is it possible to hide this? Ex, something like view.setPreviewWidget( NULL ), although this breaks the program EDIT : I s...

C++ templates and object code instantiation

With this question I'd like to better understand how C++ templates system works with regards to this question. As far as I know, template-based classes and functions are usually placed into header files. This is due to the technical issue of managing generic data types, which characterstics are unknown in principle. As soon as they are ...

pthread_create ENOMEM around 32000 threads

The process running get stuck around 32 000 (± 5%) ~# cat /proc/sys/kernel/threads-max 127862 ~# ulimit -s stack size (kbytes, -s) 2048 free memory available : 3,5 Go Further more when I try basic command while the process is stuck like "top", I get the bash message : can't fork, not enough memory. Even if there is stil...

General Socket Question - Transferring C++ Structs from Java to C++

Hi, friends. I have a general socket programming question for you. I have a C struct called Data: struct data { double speed; double length; char carName[32]; struct Attribs; } struct Attribs { int color; } I would like to be able to create a similar structure in Java, create a socket, create the data...

modify inRangeS for hsv color filtering

Hi, I'am currently trying to use cvInRangeS to check that the hue value of an HSV image is in some range. The problem is cvInRangeS allows the specification of only ONE continous range. In the following example is 20<=H<40 , 0<=S<255 , 0<=V<255 . CvScalar lower = cvScalar (20, 0, 0); CvScalar upper = cvScalar (40, 255,255); cvInRange...

Maintaining ABI: adding constructor to struct

We have a struct in revision 1 of a shared library that we need to maintain the ABI for: struct Person { std::string first_name; std::string last_name; } In the revision 2, we're changing Person to this: class Person { public: Person(const std::string &f, const std::string &l); std::string first_name; std::string...

c++ string stream

I have a double value which I receive from an application. I am trying to push onto the string stream object. For ex: if the value of varialbe is 1000000, while pushing on to the string stream, it gets pushed as 1e+06. Whats the most elegant way to convert this to string which I can use as "1000000" and not as "1e+06" ...

C++ Performance of structs used as a safe packaging of arrays

In C or C++, there is no checking of arrays for out of bounds. One way to work around this is to package it with a struct: struct array_of_foo{ int length; foo *arr; //array with variable length. }; Then, it can be initialized: array_of_foo *ar(int length){ array_of_foo *out = (array_of_foo*) malloc(sizeof(array_of_foo)); out...