c++

What is/are the Python equivalent(s) to the Java Collections Framework?

The Java Collections Framework is like the C++ Standard Template Library: "a unified architecture for representing and manipulating collections (objects that group multiple elements into a single unit)." http://java.sun.com/docs/books/tutorial/collections/intro/index.html ...

Advantages of std::for_each over for loop

Are there any advantages of std::for_eachover for loop? To me, std::for_each only seems to hinder the readability of code. Why do then some coding standards recommend its use? ...

Dependency on Derived class constructor problem

Hello Group, I am working on a legacy framework. Lets say 'A' is the base-class and 'B' is the derived class. Both the classes do some critical framework initialization. FWIW, it uses ACE library heavily. I have a situation wherein; an instance of 'B' is created. But the ctor of 'A' depends on some initialization that can only be perf...

Dealing with char ** argv

How do I assign a sequence of character strings to a char ** argv variable in a program? Its a command line argument. I'm currently trying to convert an .exe app to a dll. For example: { "string1", "string2", "string3" } --- > char ** argv variable My problem is somehow realted to this: http://stackoverflow.com/questions/1015944/ho...

C++ linked-list legacy code to STL -- allocating linked list size on the fly.

hi, I am working on some legacy code that defines a linked list (not using STL container) I want to convert this code so as to use STL list. As you can see in the following example, the linked list is assigned an initial value for all Ns. Then certain elements in the list are assigned some value. Then the "empty elements" in the list a...

How do I write shell extension context menu in C++ Builder 2010?

I'm looking for some examples for writing a shell extension in C++ Builder 2010 (2007 and 2009 would also probably be relevant) so I can right click a file in Explorer and get the file path in my VCL program. I have followed Clayton Todd's tutorial, but it's from 2001, and I have some trouble getting it to work. I can't get it to call m...

Java & memory management

Dear StackOverflow, I'm new to java world from C++ background. I'd like to port some C++ code to Java. The code uses Sparse vectors: struct Feature{ int index; double value; }; typedef std::vector<Feature> featvec_t; As I understood, if one makes an object, there will be some overhead on memory usage. So naive implementation of Fea...

how to convert a decimal number into 64 bit floating point number in C program?

I am working on block compressed sparse row format of sparse matrix. I need to convert a nonzero element into 64 bit floating point. I need a syntax in c OR C++ for that? ...

Giving up control: machine code generation vs memory layout?

This may be a bit off topic of "right answer, not discussion." However, I am trying to debug my thought process, so maybe someone can help me: I use compilers all the time, and the fact that I'm giving up control over machine code generation (the layout of my caches, and the flow of electrons) does not bother me. However, giving up co...

adding win32 app icon to task bar

I want to add some simple win32 application's icon to task bar while app is running in background. During this time, i want to send some msgs to that icon so that it pops up as per my req. Unfortunately i know only c\c++ and i use visual studio8, is there a way or api to do this? example: outlook icon or wifi icon ...

Displaying a cvMatrix containing complex numbers (CV_64FC2)

Hi, I'm new to OpenCV, and I would like to compare the results of a python program with my calculations in OpenCV. My matrix contains complex numbers since its the result of a cvDFT. Python handles complex numbers well and displays it with scientific notation. My C++ program is not effective when trying to use std::cout. I tried to sto...

Passing by reference [C++], [Qt]

Hi, I wrote something like this: class Storage { public: Storage(); QString key() const; int value() const; void add_item(QString&,int); private: QMap<QString,int>* my_map_; }; void Storage::add_item(QString& key,int value)//------HERE IS THE SLOT FOR ADDING { *my_map_[key] = value; } and when I'm trying to add...

add element to xml file with xerces

i have an xml file named LOD.xml and in this file there is a list of models. i want to add another DomElement to this file. i dont want to parse all the list again. i just want to parse file and get DomDocument and RootDomElement. after appending my new DomElement to the RootDomElement, i want to write DomDocument to this file back aga...

Create .deb package for a Qt project

Is there some sort of an automated way of creating .deb packages from a project.pro file? I tried ubucompilator without much luck. Thanks! ...

Why does std::for_each(from, to, function) return function?

I just read the code for std::for_each: template<class InputIterator, class Function> Function for_each(InputIterator first, InputIterator last, Function f) { for ( ; first!=last; ++first ) f(*first); return f; } and could not see any good reasons for this template function to return the input function. Does anyone have any exampl...

Debugging a big double array.

Hello, I am using a C++ library that provides an object that, for the sake of simplicity, is more or less like this: class ExampleSO { public double* narray; }; I have an instance of ExampleSO whose narray is about 200. Some other method ExampleSO::method() does a lot of arithmetic functions with this array and assigns it to diff...

Inherited class "invalid pointer error" when calling virtual functions.

As you can see in the code below, I have an Abstract Base Class "HostWindow", and class that derives from it "Chrome". All the functions are implemented in Chrome. The issue is, I can't call functions in Chrome if they're virtual. class HostWindow : public Noncopyable { public: virtual ~HostWindow() { } // Pure virtual function...

Force deletion of slot in boost::signals2

Hi! I have found that boost::signals2 uses sort of a lazy deletion of connected slots, which makes it difficult to use connections as something that manages lifetimes of objects. I am looking for a way to force slots to be deleted directly when disconnected. Any ideas on how to work around the problem by designing my code differently ar...

MPI , Sungrid vs JPPF ?

Greetings , I have a little experience with SungridEngine and MPI (using OpenMPI). Whats the different between these frameworks/API and JPPF ? ...

boost memorybuffer and char array

Hello, I'm currently unpacking one of blizzard's .mpq file for reading. For accessing the unpacked char buffer, I'm using a boost::interprocess::stream::memorybuffer. Because .mpq files have a chunked structure always beginning with a version header (usually 12 bytes, see http://wiki.devklog.net/index.php?title=The_MoPaQ_Archive_Format#2...