c++

Detecting TCP Client Disconnect

If I'm running a simple server and have accept()ed a connection from a client, what is the best way to tell when the client has disconnected? Normally, the client in this case I supposed to send a close command, but what if it DCs manually? How can I tell or handle this? ...

what is the difference between atan and atan2 in c++ ?

what is the difference between atan and atan2 in c++ ? ...

How do you organise your STL headers?

I am working on a large project that uses the STL and have a question about your preferred way to organise your STL #includes. Do you prefer to #include each header in the source file it is used. For example, if both foo.cpp and bar.cpp require std::string, then both will #include <string>. Do you prefer to have a single header file t...

string to const char*

This line: strcat(query,*it); (where *it is an iterator to a string) Keeps giving me this error: no matching function for call to \`strcat(char[200], const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)' I guess it's because strcat takes in a char* while *it is a string. How do I convert it from a str...

Using C++ from Objective C : how to allocate/deallocate?

Currently, my Objective C classes use C++ objects by doing a new when the owner is created, and calling delete when it is destroyed. But is there another way? I'd like to be able to declare, say, an auto_ptr whose scope lasts the duration of the Objective C class' lifetime. ...

STL Migration issues (VS 2003 -> 2005)

I have just converted a project from Visual Studio 2003 to 2005 and although most of it 'converted' fine, I have a series of STL errors from the following line: void SomeFn( std::vector<CSomeObject*>::iterator it, std::vector<CSomeObject*>::iterator itBegin = NULL, std::vector<CSomeObject*>::iterator itEnd = NULL ); The Visual Studio ...

C And C++ Coding Standards

What are best practices with regards to C and C++ coding standards? Should developers be allowed to willy-nilly mix them together. Are there any complications when linking C and C++ object files. Should things like socket libraries that traditionally is written in C remain in C and kept in seperate source files? That is keeping c code...

Memory leak detection under Windows for GNU C/C++

What memory leak detection tools are available for use with open source C/C++ on Windows? ...

How can I call a C++ function from C#?

How can I call a C++ function from C# .NET? ...

Is there a C++ unit testing framework plugin available for NetBeans?

I'm starting a new project and my company has standardized development on NetBeans. I need to do unit testing, though, and can't find a unit testing plugin for C++. As I said, it's a new project, so I'm open to trying any C++ unit testing framework. EDIT: I've decided on CppUnit, since I'm very familiar with JUnit and the learning cu...

c++ STL set difference

Does the C++ STL set data structure have a set difference operator? ...

C++ Arrays: conversion of contained type

What is the best way to convert a fixed length string array to a fixed lengh integer array in C++ ? ...

What Windows API do I choose for a rich client application?

I develop rich client software on Mac OS X and Linux. I wish to port an application to Windows and not being a user of Microsoft products, I'm not very familiar with Windows in general. What I'm familiar with: On Mac OS X, I have the option of Cocoa and Objective C or Carbon and C/C++. On Linux, I have the option of GTK+ and C/C++ or Q...

script for actionscript/flash and c++

I havent used flash or action script much. I am planning a small project that i'd like to be online via flash but i'd like to reuse the code in my c/c++ projects Is there a script language i can use? i am thinking lua or python. After googling i found flua which is incomplete and jython. Can i use java in flash? would it be a good idea ...

What settings should I be using with Minidumps?

Currently we call MiniDumpWriteDump with the MiniDumpNormal | MiniDumpWithIndirectlyReferencedMemory flags. That works just fine for internal builds in Debug configuration, but isn't giving as much information as we need in Release configuration. In Release, the minidump data contains enough stack information for the debugger to work ou...

delete or virtual delete?

I am writing a lib and a demo project. The project doesn't care which version of the lib I use (I can use sdl, directx or whatever I like as the gfx backend). To get the object I do Obj *obj = libname_newDevice(); Now, should I use delete or should I do obj->deleteMe();? I ask because I am not exactly doing new so I shouldn't be doin...

How can you initialize a class with a reference member from a private constructor?

I'm creating an interface wrapper for a class. The member within the class is a reference(to avoid copying the large structure). If I create a private constructor, what is the best way to initialize that reference to appease the compiler? struct InterfaceWrapper { InterfaceWrapper( SomeHugeStructure& src ):m_internal(src){}; i...

MSXML Select Nodes Not Working

I am working on an automated testing app, and am currently in the process of writing a function that compares values between two XML files that should be identical, but may not be. Here is a sample of the XML I'm trying to process: <?xml version="1.0" encoding="utf-8"?> <report xmlns="http://www.**.com/**"&gt; <subreport name="RBDRep...

How do you declare arrays in a c++ header?

This is related to some other questions, such as: this, and some of my other questions. In this question, and others, we see we can declare and initialise string arrays in one nice step, for example: const char* const list[] = {"zip", "zam", "bam"}; //from other question This can be done in the implementation of a function with no bo...

Can Boost Spirit be used to parse byte stream data?

Can Spirit (part of Boost C++ library) be used to parse out binary data coming from a stream? For example, can it be used to parse data coming from a socket into structures, bytes, and individual bit flags? Thanks! ...