c++

Best operating system abstraction?

I'm looking for something to abstract the standard operating system functionality in C/C++: span/kill a thread, send/receive a message, start/stop a timer, maybe even memory management, although I can probably handle that myself with my own buffer pool. I want to to be able to develop and unit test on Linux/windows and then recompile th...

Wrong control id for mixer API in Windows XP

Hi. I am having a problem with the Mixer API in Windows XP. I am trying to change the microphone recording level and mute state for a distinct sound device (I have multiple devices installed). Do do this, I need the MIXERLINE.dwLineID member in order to obtain MIXERCONTROL.dwControlID. I am trying to do this by passing MIXERLINE_COMP...

What C# book would you suggest for C/C++ programmer?

I want to learn C# with standard libraries. For now I know C/C++ and basic OOP concepts. I would like to learn more complex OOP also. Is there any book which matches my needs? ...

Does code in header file increases binary size?

Hello there Consider this: class Foo{ void func1(){ /*func1 code*/ } void func2(){ /*func2 code*/ } }; Case 1: class Foo in Foo.h Case 2: class Foo nicely seperated among Foo.h and Foo.cpp Various other cpp files include Foo.h My question is...Will Case 1 lead to a bigger binary...

In a makefile, how do I execute a command on each file name in variable?

I know I am doing it wrong, but I can't figure out how to organize this makefile. I define my util source files, and use some functions to define the .o files from them here: UTIL_SRC = utils/src/foo.cpp utils/src/bar.cpp utils/src/baz.cpp UTIL_OBJS = $(patsubst utils/src/%.cpp,utils/obj/%.o,$(UTIL_SRC)) This is the target that I use...

Standard Template String class: string.fill()

I need a way to create a string of n chars. In this case ascii value zero. I know I can do it by calling the constructor: string sTemp(125000, 'a'); but I would like to reuse sTemp in many places and fill it with different lengths. I am calling a library that takes a string pointer and length as an argument and fills the string with ...

Using C++ with Eclipse

I'm figuring out that there's two ways of writing C++ in Eclipse: either download the Eclipse IDE for C/C++ Developers or download the regular Eclipse for java and add the CDT plugin. What is the difference between these two? (Note that I'm already exstensively using Eclipse for Java) Thank you ...

Which is the best replacement for KProf ?

I'm searching for a "good enough" gprof output visualizer. Kprof seems unmaintained. Profiling is an important part of (speed sensitive) applications development, but I fail to find support on the major Linux IDEs. Any suggestions ? ...

Releasing python GIL in C++ code

Hi, I've got a library written in C++ which I wrap using SWIG and use in python. Generally there is one class with few methods. The problem is that calling these methods may be time consuming - they may hang my application (GIL is not released when calling these methods). So my question is: what is the simplest way to release GIL for t...

matlab in C C++ and C C++ in matlab

It seems that are several ways to call matlab in C C++ and to call C C++ in matlab. While I try to list them here, please point it out If I miss something. To call C C++ in matlab, there are also two methods. The first one is to call functions in C shared libraries. The second one is to build C C++ code into binary MEX-files, which will...

private inheritance

I dont completely understand this: class Base { public: Base() { cout<<"Base" << endl; } virtual void call() { cout<<"Base call" << endl; } }; class Derived: private Base { public: Derived() { cout<<"Derived" << endl; } }; int main(void) { Base *bPtr = ne...

Storing values of any type as type initially supplied in templated factory method in C++?

This is a slightly different question to this one ([http://stackoverflow.com/questions/1566445/accessing-a-method-from-a-templated-derived-class-without-using-virtual-functions%5D%5B1%5D) which I asked recently. I would like to create an instance of an object using a templated factory method, then from then on only be able to set and ge...

C++ sorting and keeping track of indexes

Using c++, and hopefully the STL, I want to sort a sequence of samples in ascending order, but I also want to remember the original indexes of the newly samples. For example I have a set, or vector, or matrix of samples A : [5, 2, 1, 4, 3] I want to sort these to be B : [1,2,3,4,5], but I also want to remember the original indexes of th...

Templated parameter for a template specialisation?

Hi I've got a static member of a templated class that I want defined for a sub group of classes that are templated ie: template <typename T> class FooT { private: static int ms_id; }; template <typename T> class Foo {}; template<> template<typename T> int FooT< template Foo<T> >::ms_id = 10; Sadly this throws the following error ...

Will this regex be enough to remove C++ multiline comments?

I need to parse some C++ files, and to make things easier for me, I thought about removing multiline comments. I tried the following regex : /(\/\*.*?\*\/)/, using the multiline modifier, and it seems to work. Do you think there will be any case where it will fail? ...

Most efficient way to store a mixed collection of doubles and ints

I need to store a collection of ints and doubles (representing nominal and real valued data) in c++. I could obviously store them all in a std::vector<double> , but this feels a bit wrong and doesn't get the aesthetics bonus points. I could also cook up something based on polymorphism, but I also need the collection to be really efficie...

Why must a pointer to a char array need strcpy to assign characters to its array and double quotes assignment will not work?

The first example does not work when you go to delete the pointer. The program either hangs when I add the null terminator or without it I get: Debug Assertion Failed Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) from Visual Studio 2008 //Won't work when deleting pointer: char *at = new char [3]; at = "tw"; // <-- not sure what'...

How to store TypeInfo

class A {} A a; type_info info = typeid (a); // error type_info is private i want a list list<type_info> to store the type of classes. Is there a solution? ...

Qt: TableWidget's ItemAt() acting weirdly

Hi, i'm working on a windows application, where in a dialog i query some data from Postgres, and manually show the output in a table widget. m_ui->tableWidget->setRowCount(joinedData.count()); for(int i=0; i<joinedData.count(); i++) //for each row { m_ui->tableWidget->setItem(i, 0, new QTableWidgetItem(joinedData[i].bobin.refer...

backup reg hives

Using http://support.microsoft.com/kb/240184 I'm able to open SAM, SOFTWARE, SYSTEM reg hives, but I do not know the next step to get them copied in a different backup folder? I get Access Denied when I try to use BackupRead API. Any help is much appreciated! ...