c++

Clarification regarding C++ Exception Handling / Throwing.

Consider the following code: try { int *i = NULL; i[100] = 20; catch (...) { std::cout << "Exception Caught"; } When running this code, it crashes (obviously, accessing a NULL pointer). Although, in Debug mode, Visual Studio states about an Uncaught exception, regarding write access violation.. also understandable. I expecte...

[c++] Problem with passing by reference

Can I overload a function which takes either a reference or variable name? For example when I try to do this: void function(double a); void function(double &a); I would like the caller of this function to be able to do: double a = 2.5; function(a); // should call function(double &a) function(2.3); // should call function(double a) ...

Using the same .proto file for both a C# and C++ project

I am attempting to use the same .proto file (protobuf) for a C# and a C++ project. My problem is that the C# file requires an import and some options set (protobuf-csharp-port) while the C++ file doesn't. Is there any way I can tell protoc to ignore imports/options under certain circumstances? Currently my only way around this is to cr...

How easy is Lua with Qt, compared to QtScript?

I'm just starting C++ development using Qt. However, I'm also interested in using Lua to script my app, given various articles stating its development speed (ease) for writing the workflow/ui/glue of an application. However, out of the box Qt doesn't support it, instead it includes QtScript. My question is basically should I attempt to ...

Japanese half/full width conversion

Hi all, I'm facing a character width problem in Japanese using glib::ustring. I have this string: ウェッジパンプス I want to convert it to: ウエッシパンプス Using ustring::normalize, i get this string: ウェッジパンプス (in fact, here, each character with accent fills two characters width) Is there a standard method to do this kind of processing? Is ICU b...

Resize native window

Hi Does anyone know of a cross-platform way to resize a native window - by native i mean one that runs inside of Windows', Mac's or Linux's windowing toolkit? Any help would be appreciated! ...

std::tr1::function::target<TFuncPtr> and co-/contravariance

Since I love progamming in both C# and C++, I'm about to implementing a C#-like event system as a solid base for my planned C++ SFML-GUI. This is only an excerpt of my code and I hope this clarifies my concept: // Event.h // STL headers: #include <functional> #include <type_traits> #include <iostream> // boost headers: #include <boost/...

Which STL container for ordered data with key-based access?

Let's say I have a collection of Person objects, each of which looks like this: class Person { string Name; string UniqueID; } Now, the objects must be stored in a container which allows me to order them so that I can given item X easily locate item X+1 and X-1. However, I also need fast access based on the UniqueID, as the coll...

Google protocol buffers compare

I want to compare two *Message*s or (two sub parameters) of Google protocol buffers. I don't find an API do achieve it. Any ideas? ...

Any open source server based on ACE framework?

Hi, anyone aware on open source project that uses ACE as the framework? Thanks, I. ...

How to switch view in Symbian C++?

Hi! I'm just trying to switch between Test1View and Test2View on Symbian S60 3rd FP2 edition in Symbian C++ language. I have some components on both of them, but Test2 is for another operations than Test1, so I need to switch it to Test2. I read on Nokia Forum about it, but I cannot find working code. Can somebody tell me how I can do th...

Howto resolve compiler specific runtime initialization functions for a library from the main application

What is the best practice when doing a mixed language library where the library language requires a runtime initialization? I have a problem where I'd like to create a certain library in Fortran which is to used from C++. I'd want to preserve platform independence and compiler independence if possible. Now, the two compilers I have play...

Compression problems, zlib?

Hi. I've been googling for long time already, and I still dont know how to use zlib. Could someone just give exact instructions what I have to do to use it? (MS Visual C++ 2010 on Win7 32). Please not the DLL version. Thanks in advance! EDIT: In case someone finds this with google, check the comments! ...

How to initialize last item automatically in a struct array?

I am passing an array to a function, and i am initializing it globally with some values. I am using empty string in end of array to determine the array length. Now, Is there some way to automatically initialize the array to have extra empty item in the end of it, so i have no chances to forget it from there? Just like the char[] works, ...

Define not evaluating POD?

I was going over the C++ FAQ Lite online. I was browsing inlines again since I haven't found a use for them and wanted to know how the stopped the circular dependency as showed in this answer. I first tried to do the, "Why inlines are better than defines." example with the following code: #define unsafe(i) \ ( (i) >= 0 ? (i) : -(i) ...

Does std::string::assign takes "ownership" of the string?

Hello, I have some gaps in the understanding of string::assign method. Consider the following code: char* c = new char[38]; strcpy(c, "All your base are belong to us!"); std::string s; s.assign(c, 38); Does s.assign allocate a new buffer and copy the string into it or it assumes ownership of the pointer; i.e. doesn't allocate new mem...

Reading from XML file using XmlHandler class from Forum Nokia - Symbian C++

Hi! I'm trying to use XmlHandler class ( link to Forum Nokia with code of XmlHandler Class ) on Symbian S60 3rd FP2 edition to read xml files. I have in my function this code: CXmlHandler *iXmlHandler; TFileName fileName; iXmlHandler = CXmlHandler::NewL(); fileName.Append( KConfigFile ); iXmlHandler->StartParsingWithAoL( fileName ); ...

Error compiling Visual Studio C++ project - error with cl.exe

Hi all, I'm running Visual Studio 2005 Pro, and have been getting the following error recently: Error 1 Error result -1 returned from 'C:\Program Files\Microsoft Visual Studio 8\VC\bin\cl.exe'. Reading some of the other posts around here, I've learned that cl.exe is native to VS 2008. I do have an install of 2008 Express (but C# onl...

Adding a new page in MS Word using Qt

Hi, I am using Qt 4.5 and using ActiveQt to generate MS Word documents. I am able to create a document based on the ActiveX commands of VBA for MS Word. But I am not able to create a new page at the desired position. I tried selection->dynamicCall("InsertBreak(const QString &)","wdPageBreak"); selection->dynamicCall("InsertParagraph(...

Is it correct/proper to use DialogBox as the main window ?

Is it correct-proper as in windows doesn't say it's bad or not recommended. For example like this: int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PAR...