c++

HTTP Content-Length incorrect size served?

I'm serving some files locally via HTTP using QTcpSocket. My problem is that only wget downloads the file properly, firefox adds four extra bytes to the end. This is the header I send: HTTP/1.0 200 Ok Content-Length: 382917; Content-Type: application/x-shockwave-flash; Content-Disposition: attachment; filename=file.swf; This i...

C++ typedef and struct question

typedef struct { int y; int weight; struct edgenode * next; }edgenode; This code is giving error : 'edgenode' : redefinition; different basic types It works fine in C code. Why? ...

std::map and -fno-implicit-templates

I am trying to compile with g++ 4.4 and link a simple program that uses the STL. I am trying to do it using the -fno-implicit-templates so all templates must be instantiated explicitly. I don't understand why this code works: #include <map> //template class std::map<char,char>; template class std::_Rb_tree<char, std::pair <char const, ...

C++\Win32 API - Difference between WC_BUTTON and "BUTTON" window classes

Is there a difference or is it as simple as #define WC_BUTTON "BUTTON"? Also, if I use InitCommonControlsEx in place of InitCommonControls, do I still need to include a manifest? ...

Simple interactive prompt in C++

Hello, I work on an application that usually runs unattended. Now I need to add to it something like an interactive prompt. In the interactive mode the operator will be able to give simple commands to the application - nothing fancy, simple commands like start and stop. Parametrized commands (e.g. repeat 10) and commands history could b...

Premature optimization or am I crazy?

I recently saw a piece of code at comp.lang.c++ moderated returning a reference of a static integer from a function. The code was something like this int& f() { static int x; x++; return x; } int main() { f()+=1; //A f()=f()+1; //B std::cout<<f(); } When I debugged the application using my cool Visual Studio debugger ...

Simplest way to automate ticket adding in Trac from C/C++

Hello, I developing program and i writing error handler, i want to do in her automate error ticket adding to trac webapge. Anyone know simplest way to do this? Simplest of connecting libcurl to PHP script on server who adding ticket. Maybe some library to do this? Or working code snipet? ...

How do I create overloaded operators for boost pointers in C++?

From this post I see that you can't overload operators for pointers: http://stackoverflow.com/questions/1419997/c-operator-overloading-of-for-pointers-to-objects But is there any way I could overload operators for boost pointers? For example: boost::shared_ptr<ClassB> operator||(boost::shared_ptr<ClassA> lhs, boost::shared_ptr<ClassA...

vcl.h: No such file or directory

I'm looking to compile some old source code in Visual C++. However, the first of many errors I am receiving is: vcl.h: No such file or directory This appears to be in reference to the Visual Component Library, native to Borland compilers it seems. I downloaded the free Borland C++ 5.5 command line compiler, but it doesn't seem to co...

How to deal with NaN's when reading in a csv file in C++

Hi, I'm reading in a csv file of time-series data into a C++ program. My data however contains some NaN's. For example: 1-Jul-2010, 1.0 2-Jul-2010, 2.0 3-Jul-2010, NaN 4-Jul-2010, 3.0 To deal with this I wrote a short script in Matlab which replaces all the NaN's with 0.0 - I then read in the new file without the NaN's. I...

OpenGL Nvidia Driver 259.12 texture not working

My OpenGL application which was working fine on ATI card stopped working when I put in an NVIDIA Quadro card. Texture simply don't work at all! I've reduced my program to a single display function which doesn't work: void glutDispCallback() { //ALLOCATE TEXTURE unsigned char * noise = new unsigned char [32 * 32 * 3]; memset(noise, 255...

API For KMP or Boyer-Moore string pattern matching in C++ / STL?

Wondering, if I want to replace strstr with a better string matching algorithm, like KMP or Boyer Moore, is there one in C++ or do we have to write on our own? Wondering, what is the practical string matching function that everyone uses other than strstr? This is with respect to C++/STL under Unix/Linux platform. ...

How to create combobox with images in Gtk ?

Hi ! Can anyone please tell me how to create a combobox like following with Gtk (on Linux)? (I already ask this question for win32 API). A code example or tutorial will be very helpful. I have tried searching this over the internet, but unfortunately documentations/tutorials aren't that much rich for Gtk. Thank you very much. Rega...

Implementation suggestions for creating an expression later used to evaluate the contents of a map in c++?

...

Reverse iterating with 2 loops?

Basically I want to reverse iterate through 2 std::vectors. a layer has a vector of shapes. usually I could do something like this: for(int i = 0; i < layers.size(); ++i) { for(int j = 0; j < layers[i].shapes.size(); ++j) { layers[i].shapes[j].dosomething(); } } However right now I need to reverse iterate through the v...

Single Responsibility in C++ - Should I implement it using friend classes or more accessors?

I wish to follow the Single Responsibility principle in C++. However, as I break up classes, it seems that in order for classes to "see" each other, I have the following choices: Add many more accessors for each class Make classes friends of each other Improve the design (maybe the fact that I would have to do 1 or 2 indicates a flaw ...

Use CreateWindow(Ex) to create a dummy parent control (like a panel)

So basically, I have a Tab Control (WC_TABCONTROL) and I want to place all of the controls that go with a single tab page on a single window (control, if you will, or panel). I want to create something like the panel in wxWidgets, so that when I call ShowWindow(panel, SW_HIDE), I can hide the panel and all controls inside it. I hope you ...

Using unique dynamic variable names (not variable values!)

Ok so, this is more a sanity check than anything else. Lets asume we have a struct called lua_State, now I need to create a uncertain amount of unique lua_State's. To make sure I don't use the same variable name twice I would need to have some sort of way to get an unique variable every time i make a new state. However there is only on...

Quick GDB Question; what does it mean if multiple memory locations are showing up as ??

#1089 0x9999992f in ?? () #1090 0x50409a99 in ?? () #1091 0x666666a6 in ?? () #1092 0x31306666 in ?? () #1093 0x35343332 in ?? () #1094 0x39383736 in ?? () #1095 0x33323130 in ?? () #1096 0x37363534 in ?? () #1097 0x31303938 in ?? () #1098 0x35343332 in ?? () #1099 0x39383736 in ?? () #1100 0x91403130 in ?? () #1101 0x9999992f in ?? () #...

Templated list of templated objects in C++

I'm trying to create a list of objects, where each object also stores 'ownership' - ie, it knows which list holds it. In a non-template situation, it's straightforward: class FooList; // forward declaration class FooItem { public: FooList *owner; ... }; class FooList: private std::list<FooItem> { ... }; However, the lis...