c++

In need to program an algorithem to be very fast, should I do it as php extension, or some otherway?

Most of my application is written in PHP ((Front and Back ends). There is a part that works too slowly and I will need to rewrite it, probably not in PHP. What will give me the following: 1. Most speed 2. Fastest development 3. Easily maintained. I have in my mind to rewrite this piece of code in CPP as a PHP extension, but may be I a...

Which is better code for converting BSTR parameters to ANSI in C/C++?

So far I've discovered I can convert incoming BSTRs to ANSI in two (of many?) ways, and I'm curious to know whether one is "better" than the other with respect to speed / efficiency etc. The way I've been using for a while is use the USES_CONVERSION and W2A macros, e.g. BSTR __stdcall F(BSTR p1, BSTR p2 ) { USES_CONVERSION; LP...

How do display functions like sprintf convert numbers to strings?

I'm trying to extract the integer and decimal parts of a floating point value, and I seem to be running into some strange rounding problems, due probably to the imprecise way floats are stored. I have some code like this to extract the fractional part: double number = 2.01; int frac = int(floor(number * 100)) % 100; However the resu...

How do I skip reading a line in a file in C++?

The file contains the following data: #10000000 AAA 22.145 21.676 21.588 10 TTT 22.145 21.676 21.588 1 ACC 22.145 21.676 21.588 I tried to skip lines starting with "#" using the following code: #include <iostream> #include <sstream> #include <fstream> #include <string> using namespace std; int main() { while( getline...

Name mangling of c++ classes and its member functions ?

Is there no way I could avoid name mangling of C++ classes and its member functions when exposed from a c++ dll. Can't I use a def file mechanism in this regard ? ...

Makefiles on windows with g++, linking a library

Hi, I've gotten fed up with MSVC++6 and how everyone is always telling me that it's a crappy compiler and such.. So now I've decided to try to use vim plus g++ and makefiles. Anyway here's my problem.. I have the following makefile # This is supposed to be a comment.. CC = g++ # The line above sets the compiler in use.. # The next li...

mpeg 2 decoding

I want to understand how video and audio decoding works, specially the timing synchronization (how to get 30fps video, how to couple that with audio, etc.). I don't want to know ALL the details, just the essence of it. I want to be able to write a high level simplification of an actual video/audio decoder. Could you provide pointers to ...

DDS texture loading

How would I load a dds texture file into an OpenGL 2dtexture or cube map texture? ...

Is there any reason to use this->

I programmed in C++ for many years and I still have doubt about one thing. In many places in other people code I see something like: void Classx::memberfunction() { this->doSomething(); } If I need to import/use that code, I simply remove the this-> part, and I have never seen anything broken or having some side-effects. void Cla...

Creating new exception in C++

Hello, I have a c++ class and I am trying to run it in ubuntu: #ifndef WRONGPARAMETEREXCEPTION_H_ #define WRONGPARAMETEREXCEPTION_H_ #include <iostream> #include <exception> #include <string> using namespace std; #pragma once class WrongParameterException: public exception { public: WrongParameterException(char...

MAP file analysis - where's my code size comes from?

I am looking for a tool to simplify analysing a linker map file for a large C++ project (VC6). During maintenance, the binaries grow steadily and I want to figure out where it comes from. I suspect some overzealeous template expansion in a library shared between different DLL's, but jsut browsign the map file doesn't give good clues. ...

Is C++ friendship among peers healthy?

Although class friendship is one of the last resorts of C++, does this pattern make sense? class Peer { public: friend class Peer; void GetSecret(const Peer& other) { const std::string& secret = other.GiveSecret(); std::cout << secret << std::endl; } private: const std::string& GiveSecret() const { ...

Saving an array value into a double variable

Greetings everyone. Having an issue compiling my script containing the following function. Three errors occur, all on the same line where I set distance += to distances [][]: error C2108: subscript is not of integral type error C2108: subscript is not of integral type error C2297: '+=' : illegal, right operand has type 'double (*)[15]' ...

in C++, can I derive a class from a struct

The question says it all really. Am I allowed derive a class from a struct, or should I create a class that embeds my struct and defines copy constructors and an = operator to move between the two? ...

C++ UML Class Diagram Autogeneration

Is there a tool which will take a set of c++ headers and output UML class diagrams? ...

How can I index a lot of txt files? (Java/C/C++)

I need to index a lot of text. The search results must give me the name of the files containing the query and all of the positions where the query matched in each file - so, I don't have to load the whole file to find the matching portion. What libraries can you recommend for doing this? update: Lucene has been suggested. Can you give m...

send(), returns Winsock Error 10038

Problem: Call to send(), returns Winsock Error 10038 against socket handle Illustration: acceptedSocket = accept (server, (sockaddr *)&sin, &len); accept(), returns 0 A new thread, is created for each connection send(), (in thread function) returns 10038 Illustration: - in thread function //omitted SOCKET RemoteSocket = (SOC...

IDE Module for Hand Drawing?

I'm currently looking for a hand drawing (2D) library/module (that would be like Paint, Paint.Net or Photoshop - but I don't need all the power of Photoshop...) that would allow me to add a drawing module to an IDE application. That application is in it's early design phase : for instance I'm only estimating if I will be able to work on...

Is it possible to statically link Qt::phonon on windows?

Because of the dependency on DirectShow on windows, is it possible to use a static Qt with my application? ...

Bug in Visual Studio C++ compiler?

This code behaves weird in MS Visual Studio: char *s = "hello"; s[0] = 'a'; printf(s); In release build with optimization turned on it ignores s[0] = 'a' and prints "hello". Without optimization or in debug build it crashes with access violation. Is this behavior is c++ standard compliant or no? In my opinion, compiler should only all...