c++

Produce SoapHeader with only one node/tag inside for C++

I have researched all MSDN information on SoapHeaders and have built the solution the way Microsoft says to. That actually happens to be my problem. What they suggest is that you create a class derived from the SoapHeader class and include a string member to hold the value for the header. The problem is that the SoapHeader class crea...

Visual Studio 2008 C++ misreporting memory address location

I'm attempting to debug a stack overwrite (no pun intended) corruption problem with some c/c++ code in Visual Studio 2008. When I compile the solution in win32 debug mode, I'm able to run the debugger and see a class get instantiated. In the constructor call, we initialize some fixed length char[] member variables using memset. If I u...

Wrap std::vector of std::vectors, C++ SWIG Python

I want to wrap a C++ vector of vectors to Python code by using SWIG. Is it possible to wrap this type of vector of vectors? std::vector<std::vector<MyClass*>>; In the interface file MyApplication.i I added these lines: %include "std_vector.i" %{ #include <vector> %} namespace std { %template(VectorOfStructVector) vector<vecto...

Bluetooth device local name

Hi, i have problem i can't solve for a while. For one of my C++ projects i have to write function to change Bluetooth radio local name. It uses Microsoft Bluetooth stack. You can find this name if you open any Bluetooth dongle device properties and navigate to Advanced Properties. I need this without any third-party libraries, only WinAp...

Storing and retrieving multiple keys in C++

I have a few integer keys that is needed to retrieve a value. What is the most efficient way to store and retrieve the value based on the keys? Currently I am converting and combining the three keys into a single string and store the key-value pair in a map. However, I think there should be a more efficient way of doing that based on t...

Python vs. C++ for an application that does sparse linear algebra

I'm writing an application where quite a bit of the computational time will be devoted to performing basic linear algebra operations (add, multiply, multiply by vector, multiply by scalar, etc.) on sparse matrices and vectors. Up to this point, we've built a prototype using C++ and the Boost matrix library. I'm considering switching to...

Does map::iterator yield lvalues ?

In other words, when i is a map<K,V>::iterator, do the following provide the expected semantics (ie. it modifies the map): *i = make_pair(k, v); i->first = k; i->second = v; ? Update: The first two lines are invalid, since the return value of operator* is (convertible to?) a pair<const K, V>. What about the third line ? Assuming a y...

Unresolved external symbol: @12 vs @8 at the end of symbol name

Hi all, I don't have any significant experience with C++ but recently had to be involved into the project with C++ part (apache modules, actually). Right now I am just trying to build some existing very much legacy code and face the very weird problem when VC++ linker cannot find one particular function in the apache library (while see...

Non-virtual derivation: what do I really get from the compiler?

Hi, I am wondering what is produced by the compiler when using non-virtual derivation: template< unsigned int D > class Point { int[D]; // No virtual function // ... }; class Point2 : public Point<2> {}; class Point3 : public Point<3> {}; Does the derivation here only imply compile-time checks? Or is there some other ove...

GetDlgItem() returns null in vc++ 2010

I recently converted a visual studio 6.0 project to visual studio 2010 and I'm encountering an issue whenever calling GetDlgItem on certain items. The following code is failing. CWnd *pWnd = (CWnd*) GetDlgItem(IDC_BATCH); pWnd->GetWindowText(szBatchNum); I see this code in my resource file for the form that's calling the above code. ...

C++ syntax question

Hello, I'm very new to c++, please help me to figure out how these operators work class MyCalss : public State // MyClass inherits State? { private MyClass(){} // Constructor for MyClass? MyClass(const MyClass&); // const means that invoking object will be not changed? What the meaning of '&' symbol? MyClass& MyClass& operator = (con...

How can I assign a child class to a base class?

I know there are solved questions related to this issue, but I still can't figure out how to resolve my problem. I have something like this: class Base { static Base* createBase() { Base *b = new Base(); ... //does a lot of weird things return b; } } class Child : public Base { static Child* createChild()...

how to sort a set using a Functor

hey, i am trying to sort my set container using afunctor: struct CompareCatId : public std::binary_function<Vehicale*, Vehicale*, bool> { bool operator()(Vehicle* x, Vehicle* y) const { if(x->GetVehicleType() > y->GetVehicleType()) return true; else if (x->GetVehicleType() == y->GetVehicleType() ...

Redirect stdout to Visual Studio output window from native c++ dll

I have a c# windows app that calls a managed c++ dll, which, in turn, calls a native c++ dll. There seem to be some performance issues in the native c++ code, so I'm doing some simple profiling. I'd like to dump the results of the profiling so that the Visual Studio output window picks it up. I thought that printf would do the trick, but...

"Error: no operator for cin>>" I can't figure out what I'm doing wrong here

I'm a student and just started learning C++ last week so this question is probably very low level but I can't figure it out. I've searched around a bit but can't find any results, or maybe I'm looking for the wrong thing. There are two cin parts. One taking in an int outside the loop, the other taking in a string inside the loop. I'm ...

How to assign keys on physical position at the keyboard on Windows?

There are at least 3 different keyboard layouts who are using the program i make, and i dont care which key they press, the more important thing is where the keys are pressed. I cant just ask the user to press 100 different keys/combinations, that would take too much time and be very confusing to the user. Is there some library or som...

Generate Mapfile

We have a ELF binary for which I want to generate a map file to find the addresses of functions and other details. But I am getting the below warning via ld. Is the command correct - box 225> ld -M c++_aplication ld: warning: i386 architecture of input file `c++_aplication' is incompatible with i386:x86-64 output I tried with differe...

ANSI C equivalent of try/catch?

I have some C code I'm working with, and I'm finding errors when the code is running but have little info about how to do a proper try/catch (as in C# or C++). For instance in C++ I'd just do: try{ //some stuff } catch(...) { //handle error } but in ANSI C I'm a bit lost. I tried some online searches but I don't see enough info abou...

Am I allowed to throw an exception inside MPI-parallelized code?

These are some general questions I am facing while designing the error handling for an algorithm that is supposed to run in parallel using MPI (in C++): Do Exceptions work inside code that is executed in parallel? Is the behaviour defined? How do they work? Does that differ for different implementations? Is it good practice - or should...

Operations on 1-D array

How to insert and delete an element of a 1-D array. for ex: suppose the array is: 1 3 4 2 5 we want to insert 7 between 3 and 4 so that the new array is: 1 3 7 4 2 5 ...