c++

Spawned processes becoming defunct

I use posix_spawnp to spawn child processes from my main process. int iRet = posix_spawnp(&iPID, zPath, NULL, NULL, argv, environ); if (iRet != 0) { return false; } Sometimes, after a child process is spawned without errors, it suddenly becomes defunct. How could this occur? I use a signal handler to rea...

Boost is just great and free ... Is there a catch?

The reason for this, I find myself being asked to make replacement classes for boost's classes in a commercial project. And I am asked to test them against the boost class's behaviour. This makes absolutely no sense to me. I seldom see a license as open as boost's. Maybe there will be added functionality in the future, but since boost'...

Is there a way to group a set of soap methods logically in a "class" type entity?

Hi all. For our large C++ based project we now have a method to automatically generate code to expose our code as SOAP methods. This works really well, and we are planning to start implementing an RIA based application using Adobe AIR / Flex based on the API's we have exposed. The question I have is about organizing SOAP webservices...

error C2664: in c++?

for (int v = 0; v <= WordChosen.length();v++) { if(Letter == WordChosen[v]) { WordChosenDuplicate.replace(v,1,Letter); } } I get this error "Error 4 error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::replace(__w64 unsigned int,__w64 unsigned int,const std::basic...

What's the use of .map files the linker produces?

What is the use of .map files VC++ linker produces when /MAP parameter or "Generate map file" project setting is used? When do I need them and how do I benefit from them? ...

How to add element to C++ array?

i want to assign an int into an array, but the problem is i dont know what is the index now. int[] arr = new int[15]; arr[0] = 1; arr[1] = 2; arr[2] = 3; arr[3] = 4; arr[4] = 5; that codes work because i know what index i am assigning to, but what if i dont know the index.. in php i can just do this arr[]=22; this will automaticall...

initialize variable involving vector data type

I have the following data types and variables: typedef Seq< vector<int> > MxInt2d; typedef std::vector<int> edge_t; typedef std::vector< edge_t> edge2d_t; std::vector< edge2d_t > myEdgesIntersect; I tried to initialize myEdgesIntersect like: edge2d_t edge2d(2); //creating the vector of edges of intersections whenever an intersect...

Configuring File DSN

How to invoke configure dialog for a File DSN from C++ program? I can do it for System/user DSN using SQLConfigDataSource. Thanks in advance, Manoj ...

How does delete deal with pointer constness?

I was reading this question Deleting a const pointer and wanted to know more about delete behavior. Now, as per my understanding: delete expression works in two steps: invoke destructor then releases the memory (often with a call to free()) by calling operator delete. operator delete accepts a void*. As part of a test program I over...

How do I call array of linked list in main?

I have a class here that contain linked list of other class cars example class transportation { private; int id; list <car> *cars; int keyval; public : set() { } void setTransportation(int ids, list <car> *carss, int keyvals) { id=ids; cars[keyvals]=carss[keyvals]...

What are the drawbacks to compiling C++ projects with /clr:safe to enable unit testing?

I would like to introduce unit testing to our C++ product and wanted to investigate the pros and cons of trying to use the CLR-based unit tests. I've read that if you compile with the /clr:safe option, you can call your existing C++ code. I'm strictly a .NET developer, so I'm at a loss for how this would affect our codebase. What shou...

Checking real variable type in polymorphism (C++)

Suppose we have a class A and class B and C inherit from it. Then we create an array of references to A's, and fill it with B's and C's. Now we decided that we want to eliminate all the C's. Is there a way to check what type each field of the array really holds without doing something redundant like a returnType() function? Edit: fix...

midl error 2025 when compiling idl file on win32 (midl doesn't like string<40>)

The idl files I have compile fine with linux tools, but when I try to compile using midl I get an error error MIDL2025 : syntax error : expecting a declarator or * near "<" the line is: typedef string<40> somestring; Is this non-standard idl, or am I missing something? Is there a switch for midl to allow this? I wish I coul...

Do templated classes inherit the members of the classes passed to them? (Specificly std::vector)

Hi, I have a question regarding vectors: If I have a std::vector<MyClass> will this vector "inherit" the MyClass member functions or not? If not, then would be the best way to handle individually the MyClass members inside a loop? Would I have to create a new class object on each iteration and assign the current vector iterator to it? ...

Can you resize a C++ array after initialization?

I'm learning to program, and C++ is my first language. Don't bother using pointers to show me - I don't understand them yet, and won't bother until I have more free time to dedicate to this. int mergeSort() { const int n = 9; int originalarray[n] = {1, 3, 5, 7, 9, 2, 4, 6, 8}; const int halfelements = (sizeof(originala...

What can be done in VC++ (native) that can't be done with VC#?

What can be done in VC++ (native) that can't be done with VC#? From what I can tell the only thing worth using VC++ native for is when you need to manage memory yourself instead of the CLR garbage collector, which I haven't seen a purpose in doing either (but thats for another question to be asked later). ...

Position of least significant bit that is set

I am looking for an efficient way to determine the position of the least significant bit that is set in an integer, e.g. for 0x0FF0 it would be 4. A trivial implementation is this: unsigned GetLowestBitPos(unsigned value) { assert(value != 0); // handled separately unsigned pos = 0; while (!(value & 1)) { value >>= ...

Concatenating C++ iterator ranges into a const vector member variable at construction time

I have a class X, which I provide a snippet of here: class X { public: template <typename Iter> X(Iter begin, Iter end) : mVec(begin, end) {} private: vector<Y> const mVec; }; I now want to add a new concatenating constructor to this class, something like: template <typename Iter1, typename Iter2> X(Iter1 begin1, Ite...

I'm concerned this code isn't doing what I want it to because of the way objects are used.

I have the following code and I was wondering if someone could look at it for me. I have a multi-threaded application that all share an object and operate on it. I've created a pointer to a certain element of it, just so I don't have to type in the long path every time, but I'm concerned it might simply be modifying a copy of the share...

In which order should classes be declared in C++?

Say I got this C++ code: class class1{ class2 *x; } class class2{ class1 *x; } The compiler would give an error in line 2 because it couldn't find class2, and the same if i switched the order of the classes. How do I solve this? ...