c++

Can the "using" declaration be used with templates?

Is it possible to use the "using" declaration with template base classes? I have read it isn't here but is that because of a technical reason or is it against the C++ standard, and does it apply to gcc or other compilers? If it is not possible, why not? Example code (from the link above): struct A { template<class T> void f(T); };...

How to create a non OwnerDraw Button in .NET?

Hi, I'm creating a plugin to a software that skins the form I created. However, the button are not skin based on them and a standard gray button is shown. Asking on the software forum pointed me that .NET forms control are owner-draw and therefor my button won't redraw with the correct style instead of creating a non ownerdraw button. ...

how to check performance of a c++ api

my web server has a lot of dependencies for sending back data, when it gets a request. i am testing one of these dependency applications within the web server. the application is decoupled from the main web server, and only queries are going to it in the form of api's exposed. my question is, if i wish to check these api's in a multithr...

How do you search a std::string for a substring in C++?

I'm trying to parse a simple string in C++. I know the string contains some text with a colon, followed immediately by a space, then a number. I'd like to extract just the number part of the string. I can't just tokenize on the space (using sstream and <<) because the text in front of the colon may or may not have spaces in it. Some ...

Accessing a bidimensional(or tridimensional) array through a pointer

When you have an array like this: int foo[3][2][2]; and you make: int *bar = &foo[0][0][0]; Is this the way it works? *bar == foo[0][0][0]; *(bar+1) == foo[0][0][1]; *(bar+2) == foo[0][1][0]; *(bar+3) == foo[0][1][1]; *(bar+4) == foo[1][0][0]; I'm not sure and have a bit of code dependent on if that works. ...

How can I get a specialized template to use the unspecialized version of a member function?

Consider the following code: template <int dim> struct vec { vec normalize(); }; template <> struct vec<3> { vec cross_product(const vec& second); vec normalize(); }; template <int dim> vec<dim> vec<dim>::normalize() { // code to normalize vector here return *this; } int main() { vec<3> direction; directi...

append an int to char*

How would you append an integer to a char* in c++? ...

Best Flags for Crash dumps

I currently have some code that will produce a crash dump when my application crashes however i cant work out what are the best flags to use for it are. At the moment i have it using Full Memory (MiniDumpWithFullMemory) but this produces 32mg crash files. What flags should i use as to not make the crash file huge but give me the most po...

How do I get the source IP address from a datagram's IP header with Winsock?

I have a port that is bind()'d to INADDR_ANY. I am receiving datagrams successfully. After receipt, I need to read the IP header to get the source IP address. ...

OpenMPI: All nodes run as node 0

I have a c++ program that is using the openMPI library to pass messages between different processors. It is a parallel program that uses a genetic algorithm to get a good solution for the traveling salesperson problem. I am trying to set up the MPI environment on my two dual processor computers at my house so that I can run it. When...

Inheriting constructors

...

Erasing elements from a vector

I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I need to clear all of them. My code is something like this: void erase(std::vector<int>& myNumbers_in, int number_in) { std::vector...

Watching dynamic array variables values in Xcode

Hello! I've got the dynamic array of pointers to structure. struct item { unsigned long code; //1 - 2^32 unsigned short date; //0 - (13*365+4-31)+1 unsigned char place; //1 - 200 unsigned short amount; //0 - 10000 unsigned short price; //0 - 50000 }; count = getSizeFromSomewhere(); item ** x=new item *...

How to get file list from a Debian package using eptlib libraries?

Simple question: I have loaded an Apt package record with libept. There is a method to get file list? It should sound like record.GetFileList(); and it should return a vector string like the output of dpkg -L packagename ...

IDebugControl::WaitForEvent works once then returns E_HANDLE

I'm trying to make a small tool that makes use of the Debugger Engine API, but I'm having very limited success. I can get my IDebugClient and IDebugControl instances, and from there I am able to attach into an already running user process. I then enter a main loop where I call WaitForEvent, OutputStackTrace, SetExecutionStatus(DEBUG_ST...

C++ areas you look for during interview

If you are taking an interview of an candidate without any prior work experience and want to find out how good he/she is in C++ what are the areas you generally look for ? ...

Convert std::string to const char* or char*

How can I convert an std::string to a char* or a const char*? ...

Simple anonymous pipes - what wrapper model you use? (WinAPI, C++)

I have two running processes in Windows, and each process has a pipe to the other. I want to serialize a complicated class and transmit it from one process to the other. I already have the serialization procedure worked out, and I understand that the pipes are sending binary streams. How should I go about sending my serialized data? I'm...

Open Source sound engine

When I started using SoundEngine (from CrashLanding and TouchFighter), I had read about a few people recommending not to use it, for it was, according to them, not stable enough. Still it was the only solution I knew of to play sounds with pitch and position control without learning C++ and OpenAL, so I ignored the warnings and went on w...

In C++ is it possible to have a defined purely virtual function?

Here's the deal. I have a big class hierarchy and I have this one method that is extended all the way through. The method always has to look at one or two more variable at each new level and these variable depend on the actual class in the hierarchy. What I want to do is check those two extra variables then call the superclass's version ...