c++

Deserialize a byte array to a struct

I get a transmission over the network that's an array of chars/bytes. It contains a header and some data. I'd like to map the header onto a struct. Here's an example: #pragma pack(1) struct Header { unsigned short bodyLength; int msgID; unsigned short someOtherValue; unsigned short protocolVersion; }; int main() { ...

Any recommendations for a PDF 3D SDK with C++ interface

I'm on the look out for a Cor C++ library / SDK that will allow me to either write a 3d PDF directly, or convert a DXF or DWG into a 3D PDF. So far I have come up with the PDF3d library which fits the bill, but is reasonably costly and has an expensive per user run time license. I don't mind a reasonable SDK cost, but the per seat cost...

Why can't you overload the '.' operator in C++?

It would be very useful to be able to overload the . operator in C++ and return a reference to an object. You can overload operator-> and operator* but not operator. Is there a technical reason for this? ...

Why is the linux kernel not implemented in C++?

Why is C as programming language still so prominent when it comes to OS programming? Shouldn't C++ have replaced it a long time ago as its successor? ...

Suggestion on book to read about refactoring?

Will it be easy for a C++ developer to read Refactoring: Improving the Design of Existing Code Is there any other book that I should read about refactoring? Feel free to add any articles on refactoring. ...

C/C++ private array initialization in the header file

I have a class called Cal and it's .cpp and .h counterpart Headerfile has class Cal { private: int wa[2][2]; public: void do_cal(); }; .cpp file has #include "Cal.h" void Cal::do_cal() { print(wa) // where print just itterates and prints the elements in wa } My question is how do I initialize the array ...

How can I tell the compiler not to create a temporary object?

I'm changing an old routine that used to take an integer parameter so that it now takes a const reference to an object. I was hoping that the compiler would tell me where the function is called from (because the parameter type is wrong), but the object has a constructor that takes an integer, so rather than failing, the compiler creates ...

The curious problem of the missing WM_NCLBUTTONUP message when a window isn't maximised

I've got a window that I handle WM_NCLBUTTONUP messages, in order to handle clicks on custom buttons in the caption bar. This works great when the window is maximised, but when it's not, the WM_NCLBUTTONUP message never arrives! I do get a WM_NCLBUTTONDOWN message though. Strangely WM_NCLBUTTONUP does arrive if I click on the right of th...

Decrypting RijndaelManaged Encrypted strings with CryptDecrypt

Ok I'm trying to use the Win32 Crypto API in C++ to decrypt a string encrypted in C# (.NET 2) with the RijndaelManaged Class. But I'm having no luck at all i get jibberish or a bad data Win32 error code. All my keys, IV and salt match, I've looked in the watch for both test apps. I've spent all say looking at it and I'm officialy stuc...

Unexplainable crash in DirectX app in Windows XP that uses english language

The app was working fine but now a few weeks later when the new version begun testing, it crashes. Tried it on five of the workstations, it crashes only on two of them. And the only common about them I can find is that those two have Windows installed with english language. Its a DirectX 8.1 application, written in C++ with Visual Studi...

Creating a linear gradient in 2D array

I have a 2D bitmap-like array of let's say 500*500 values. I'm trying to create a linear gradient on the array, so the resulting bitmap would look something like this (in grayscale): The input would be the array to fill, two points (like the starting and ending point for the Gradient tool in Photoshop/GIMP) and the range of values whic...

Visual Studio C++ Debugger: No hex dump?

Why is the integrated vs debugger so... barely functional? I cannot see the contents of an object in memory. For example, I am working with bitmaps and I would like to see them in memory. Do I need a better debugger for this? If so I am interested in recommendations. Nothing too powerful like a disassembler, just the debugger. ...

gsoap fault processing - sending application specific exceptions

Hello GSoap community! My application is crashing when I am sending application specific fault details. Here's how my SOAP_ENV__Detail looks like - struct SOAP_ENV__Detail { public: ex__ExceptionType *ex__Exception; /* optional element of type ex:ex__ExceptionType */ int __type; /* any type of element <fault> (defined below) ...

When to use friend class in c++

I was just brushing up on my cpp (I'm a java developer) and I came across the Friend class keyword which I forgot about for a while. Is this one of those features that's just part of the kitchen sink, or is there a good reason for doing this rather than just a vanilla getter? I understand the difference in that it limits who can access t...

Creating a C++ Class Diagram

In Visual Studio .NET projects you can add a "Class Diagram" to the project which renders a visual representation of all namespaces, classes, methods, and properties. Is there any way to do this for Win32 (not .NET) C++ projects? Either through Visual Studio itself or with a 3rd party tool? ...

event notifications not received as described

Problem: Event notifications (From COM object - Server) are not received as listed in the Sink (class) implementation. One event notification is received (Event_one), however, others are not received accordingly If order is changed - in IDispatch::Invoke, that is: if Event_one is swapped to Event_two then Event_two notification rece...

InternetReadFile Problem (error 87 - The parameter is incorrect)

Hello, I have a problem here with InternetReadFile, if I run the application in a computer without proxy, the app runs ok, but if I try to use with a computer using proxy, I receive an error 87 (The parameter is incorrect). Thats my code: conHandle = InternetOpen("Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); ... hFile = Inte...

How to develop a DirectFB app without leaving X.11 environment.

Hi folks, I'm trying to develop a GUI application for an embedded platform, without any windowing whatsoever and I'm doing that with DirectFB, and it suits my needs very fine. Since the embedded I develop for is not that powerful, I would really like to try to develop on my own Ubuntu desktop. The problem is Framebuffer is conflicting ...

Why is runtime library a compiler option rather than a linker option?

I'm trying to build a C/C++ static library using visual studio 2005. Since the selection of the runtime library is a compile option, I am forced to build four variations of my library, one for each variation of the runtime library: /MT - static runtime library /MD - DLL runtime library /MTd - debug static runtime library /MDd - debu...

Trouble examining byte code in MSVC++

I've been messing around with the free Digital Mars Compiler at work (naughty I know), and created some code to inspect compiled functions and look at the byte code for learning purposes, seeing if I can learn anything valuable from how the compiler builds its functions. However, recreating the same method in MSVC++ has failed miserably ...