c++

Getting at unmanaged C++ functions from C#

I have some ANSI standard C code which is authoritative. What that means is that although I have the source, I can not translate to another language nor modify calling arguments, as those actions would invalidate the authority. There are over 150 functions. I can make incidental changes, such as change the file names from .C to .CPP s...

Performing equivalent of "Kill Process Tree" in c++ on windows

We have a c++ task that will fork a new process. That process in turn may have several child processes. If the task runs past an allotted time, we will want to kill that forked process. However, we don't want to orphan the processes it has spawned. We want them all to die. I have used Process Explorer and it has a "Kill Process Tree...

How can I view DOMString (from apache xerces library) in MS visual studio debugger?

I am working on code (legacy code) which uses Apache Xerces-C library. I am trying to view the value of DOMString (and other related DOM objects) in Microsoft Visual Studio Debugger but in vain. I have tried the following 1) I Added the following in the autoexp.dat file: ;---------------------------------------------------------------...

Is Qt worth learning?

I am a C# developer and work on Windows, but back in High School I took some C++ classes. We worked on console applications only. I kinda want to learn C++ GUI programming. I have been looking at Qt and was wondering if I should learn it. For fun lets make this a multiple choice answer: A) Learn Qt B) Learn other C++ GUI C) Don't learn ...

C++: Convenient way to access operator[] from within class?

I have a C++ class that overloads operator[], the array subscript/brackets operator. This is awfully convenient outside of my class, where I can write foo[bar]. However, I can't figure out how to use this notation when I'm implementing methods inside my class. I know I can write operator[](bar) or this->operator[](bar) but those are f...

Treating Classes as First Class Objects

I was reading the GoF book and in the beginning of the prototype section I ready this: This benefit applies primarily to languages like C++ that don't treat classes as first class objects. I've never used C++ but I do have a pretty good understanding of OO programming, yet, this doesn't really make any sense to me. Can anyone ...

Accessing inherited variable from templated parent class

Consider the following code: template<class T> class Foo { public: Foo() { a = 1; } protected: int a; }; template<class T> class Bar : public Foo<T> { public: Bar() { b = 4; }; int Perna(int u); protected: int b; }; template<class T> int Bar<T>::Perna(int u) { int c = Foo<T>::a * 4; // This works return (a + b) * u...

Does casting to an int after std::floor guarantee the right result?

I'd like a floor function with the syntax int floor(double x); but std::floor returns a double. Is static_cast <int> (std::floor(x)); guaranteed to give me the correct integer, or could I have an off-by-one problem? It seems to work, but I'd like to know for sure. For bonus points, why the heck does std::floor return a double in t...

expand size of vector passed as memory

I am passing my vector to a function that expects a c array. It returns the amount of data it filled (similar to fread). Is there a way i can tell my vector to change its size to include the amount that function has passed in? of course i make sure the vector has the capacity() to hold that amount of data. ...

Python's PubSub/observer Pattern for C++?

Hi, i'm looking for a C++ replacement of the Python PubSub Library in which i don't have to connect a signal with a slot or so, but instead can register for a special Kind of messages, without knowing the object which can send it. ...

Table api

Suppose you have a table widget class. Do you do table.row(i).column(0).setText(students[i].surname()) or table[0][i] = students[i].surname() the latter makes way less sense but the simplicity is so luring ;) ditto for: table.row(0).column(0).setBackground(red) vs: table[0][0].setBackground(red) Note that Table::row returns a Table::...

C++ and C file I/O

C++ file i/o is tougher than c file i/o. So in c++, creating a new library for file i/o is useful or not? I mean Can anyone pls tell are there any benefits in c++ file i/o ? ...

Unit test compile-time error.

Is there a way to test compile-time errors, but without actually generating the error? For example, if I create a class which is non-copyable, I'd like to test the fact that trying to copy it will generate a compiler error, but I'd still like to execute the other runtime tests. struct Foo { int value_; Foo(int value) : value_(va...

C++ multi-dimensional data handling

Many times, I find myself having to define a container for multi-dimensional data. Let's take an example: I have many Chips, each Chip has many Registers, each Register has many Cells, and each Cell has many Transistors. At some stage of my C++ program I have to read this data, and later I have to use it. I cannot use any external sto...

How might I retrieve the version number of a Windows EXE or DLL?

How to retrieve at runtime the version info stored in a Windows exe/dll? This info is manually set using a resource file. ...

monitor with operator overloading c++

Hi, I would like to write a wrapper class with all operators overloaded such that I can detect when we write/read or modify its contents. For instance: probe<int> x; x = 5; // write if(x) { // read x += 7; // modify } Anyone already did that? If not which operators must I overload to be sure I dont miss anything? ...

Are the C++ ARM compilers bundled along with VS2008 redistributable?

Hi, Are the VS2008 C++ ARM compilers targeting the WinCE operating system redistributable? Or does Microsoft provide a separate redistributable package (SDK?) ? I am looking for a C++ ARM compiler (actually a complete build environment) for WinCE which I can distribute along with my application for free. What are my options here? ...

Launching a C# dialog from an unmanaged C++ mfc active x dll

I've been told to write a dialog in C# which must be instantiated from an unmanaged c++ dll. We do this in other places in our code by simply adding a managed c++ class to the C++ project, then calling the C# dll from the managed c++ class. However I'm finding that doesn't work for me from where I have to do it. I think because the c+...

wifstream equivalent to _wfopen's "mode" parameter?

I'm having troubles opening a Unicode file in C++ using fstreams instead of the older FILE-based file handling functions. When opening a file using _wfopen, I can specify a mode to tell it what character encoding to use. Eg: _wfopen_s(&file, fileName, unicode ? L"r+, ccs=UTF-16LE" : L"r+" ); This works fine. When using wifstream thoug...

Convert VARIANT to...?

Note: Attempting to invoke a method of an interface, of which the return type is _variant_t Code: _variant_t resultsDataString; _bstr_t simObjectNames; simObjectNames = SysAllocString (L"TEST example 3"); resultsDataString = pis8->GetSimObject (simObjectNames); inline function illustrated below, contained in .tli FILE: inline ...