c++

Isn't an Iterator in c++ a kind of a pointer?

Ok this time I decided to make a list using the STL. I need to create a dedicated TCP socket for each client. So everytime I've got a connection, I instantiate a socket and add a pointer to it on a list. list<MyTcp*> SocketList; //This is the list of pointers to sockets list<MyTcp*>::iterator it; //An iterator to the list of pointers ...

Espeak SAPI/dll usage on Windows ?

Question: I am trying to use the espeak text-to-speech engine. So for I got it working wounderfully on linux (code below). Now I wanted to port this basic program to windows, too, but it's nearly impossible... Part of the problem is that the windows dll only allows for AUDIO_OUTPUT_SYNCHRONOUS, which means it requires a callback, but I ...

Doing 64 bit manipulation using 32 bit data in Fixed point arithmetic using C.

Hi, I am stuck with a problem. I am working on a hardware which only does support 32 bit operations. sizeof(int64_t) is 4. Sizeof(int) is 4. and I am porting an application which assumes size of int64_t to be 8 bytes. The problem is it has this macro BIG_MULL(a,b) ( (int64_t)(a) * (int64_t)(b) >> 23) The result is always...

Is there an Open XML parser for C++?

Hello, I want to scan a PowerPoint 2007 file, but I'm trying to do it with C++. Is there any Open XML parser for C++? ...

Algorithm to generate dates for business days given the range of dates

I'd like to be able to calculate the dates of business days (mon-fri) given two dates d1 and d2. However in some locales the business days are sat-wed or sun-thur. Is there a facility in STL or C++ in general that allows for such a calculation? ...

WebKit and npapi and mingw-w64

Hi, The problem is the following: On Windows x64, pointers are 64-bit, but type long is 32-bit. MSVC doesn't seem to care, and even omits warnings about pointer truncation on the default warning level. Since recently, there is a GCC that targets x86_64-w64-mingw32, or better native Windows x64. GCC produces errors when pointers are trun...

CAsyncSocket and ThreadPool problem

I have a server application with such structure: There is one object, call him Server, that in endless cycle listens and accepts connections. I have descendant class from CAsyncSocket, that has overriden event OnReceive, call him ProxySocket. Also I have a thread pool with early created threads. When connection is received by server obj...

Import a shared object and call its funtions in C++.

Is it possible to import a shared object (without linking the program with it) and call any function? Thanks. ...

Problem with array of elements of a structure type

I'm writing an app in Visual Studio C++ and I have problem with assigning values to the elements of the array, which is array of elements of structure type. Compiler is reporting syntax error for the assigning part of the code. Is it possible in anyway to assign elements of array which are of structure type? typedef struct { CString...

Pointer arithmetic.

Having code: int** a = new int*[2]; a[0] = new int(1); a[1] = new int(2); cout << "a[0] " << a[0] << '\n'; cout << "a[1] " << a[1] << '\n'; cout << "a[2] " << a[2] << '\n'; cout << "a[0] + 1 " << a[0] + 1 << '\n';//WHY THIS ISN'T == a[1] ? cout << "*(a + 1): " << *(a + 1) << '\n'; //WHY THIS IS == a[1] ? cout << "a[0] - a[1] " << stat...

Formatting time in milliseconds using boost::date_time library

I have a time duration in milliseconds which I ideally would like to format using the formatting functionality present in the boost::date_time library. However, after creating a boost::posix_time::time_duration I can't seem to find a way to actually apply the formatting string to it. ...

C++ Suppress Automatic Initialization and Destruction

How does one suppress the automatic initialization and destruction of a type? While it is wonderful that T buffer[100] automatically initializes all the elements of buffer, and destroys them when they fall out of scope, this is not the behavior I want. #include <iostream> static int created = 0, destroyed = 0; struct S {...

Combining several static archives into a new one

I'm making a game engine for mobile devices. I want to compile my code, link it against a few static libraries and then combine my compiled code with those static libraries to form a new static library. However, my Google Fu is abandoning me. Suppose I have static libraries a.a, b.a and c.a and my code. I want to compile all that into ...

C++ Function pointers vs Switch

What is faster: Function pointers or switch? The switch statement would have around 30 cases, consisting of enumarated unsigned ints from 0 to 30. I could do the following: class myType { FunctionEnum func; string argv[123]; int someOtherValue; }; // In another file: myType current; // Iterate through a vector containing...

What am I doing wrong?, linking in C++

I'm trying to code a simple base64 encoder/decoder (to test my programming skill). I can compile it, but it doesn't link, I've this message error: C:\Documents and Settings\Facon\Escritorio>g++ base64.o main.o -o prueba.exe main.o:main.cpp:(.text+0x24a): undefined reference to `Base64Encode(std::vector > const&)' collect2:...

C++ Interpreter: How to emit error messages?

I want to emit dynamic error messages like all interpreters do nowadays, for example: Name error: Undefined variable would be constant, however what I want to reach is: Name error: Undefined variable 'X', in line 1 Okay. The line number was really no problem: Every error message must have a line number, so I added it to the error e...

C++ can local class reference be passed to a function?

hi I would like to know if the following is allowed: template < class C > void function(C&); void function() { class {} local; function(local); } thanks ...

What are useful functions for drawing text (MFC)?

I'm creating a line chart control, and I need to write (or better say draw) the axis names and axis values. I found DrawText and TextOut functions, but the text they show is flickering and don't know how to set the font and text orientation (I will need vertical text orientation as well as horizontal). Are there any other functions you...

Stack and queue operations on the same array.

Hi. I've been thinking about a program logic, but I cannot draw a conclusion to my problem. Here, I've implemented stack and queue operations to a fixed array. int A[1000]; int size=1000; int top; int front; int rear; bool StackIsEmpty() { return (top==0); } bool StackPush( int x ) { if ( top >= size ) return false; A[t...

C++ static variables dynamic

Is it possible or makes sense to have static dynamic variables on a class, initialized with new operator? ...