c++

Algorithm for dividing very large numbers

I need to write an algorithm(I cannot use any 3rd party library, because this is an assignment) to divide(integer division, floating parts are not important) very large numbers like 100 - 1000 digits. I found http://en.wikipedia.org/wiki/Fourier_division algorithm but I don't know if it's the right way to go. Do you have any suggestions...

Qt and auto_ptr

I just discovered the concept of an auto_ptr and am liking it! As Qt often requires a QList or QVector<(some QObject or QWidget) *>, is there any concrete reason why auto_ptr should be avoided. If I'm right, it allows you to replace this: std::vector<MyClass*> vec; /* add several elements to the vector and do stuff with them */ for(size...

How to templatize the container type in a function declaration?

I want to write a function that accepts any container holding strings. Something like this: template <typename Container> void foo(Container<string>& stuff); But this isn't the right syntax. What's the right syntax? ...

SWIG: Throwing exceptions from Python to C++

We've got an interface we've defined in C++ (abstract class, all functions pure virtual) which will be extended in Python. To overcome the cross-language polymorphism issues we're planning on using SWIG directors. I've read how to catch exceptions thrown from C++ code in our Python code here, here, here, and even on SO. It's fairly st...

Is using a C++ "Virtual Constructor" generally considered good practice?

Yes i know the phrase "virtual constructor" makes no sense but i still see articles like this one: http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=184 and i'v heard it mentioned as a c++ interview. What is the general consensus? Is a "Virtual Constructor" good practice or something to be avoided completely? To be...

How do you stop in TotalView after an MPI Error?

I am using TotalView and am getting an MPI_Error. However, Totalview does not stop on this error and I can't find where it is occurring. I believe this also applies to GDB. ...

How to create a step by step wizard in C++ (with unmanaged code) in Visual Studio 2010

I would like to build a small wizard in C++ with no dependencies on any framework. Apparently, is really simple, but I don't know where to start. Can you point me to good information (tutorials, etc) on it. Should I use MFC Application or a Win32 project? Is there any step by step guide ? I'm using VS 2010. The majority of info I'd f...

Multi-argument template functions, overloading and ambiguity errors.

Lets say I'm writing a some kind of conversion operator, and I want to use it like that: SomeType a; AnotherType b = conv<AnotherType>(a); First, I write the base (default) function: template <typename T, typename U> inline T conv(const U& a) { return T(a); } Full specialization (or a non-template overload) is not a problem, ho...

C++ How do I give a member variable in an abstract class a default value?

In the header, I'm defining bool isActive. In classes derived from this one, I would like to make isActive false by default. I tried doing this by adding AbstractClass::isActive = false; to the cpp file, but that causes the error "Expected constructor, destructor, or type conversion before '=' token." ...

std::ostream interface to an OLE IStream

I have a Visual Studio 2008 C++ application using IStreams. I would like to use the IStream connection in a std::ostream. Something like this: IStream* stream = /*create valid IStream instance...*/; IStreamBuf< WIN32_FIND_DATA > sb( stream ); std::ostream os( &sb ); WIN32_FIND_DATA d = { 0 }; // send the structure along the IStream os...

Getting a type for a template instantiation?

I have the following situation: I have a object of type MyClass, which has a method to cast itself to its base class. The class includes a typedef for its base class and a method to do the upcast. template <class T, class B> class BaseClass; template <class T> class NoAccess; template <class T> class MyClass : public BaseClass<T, NoA...

QSyntaxHighlighter highlight ascii?

How can I get the QSyntaxHighlighter to syntax highlight ascii characters like @ or #? This is my current code: Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) { HighlightingRule rule; keywordFormat.setForeground(Qt::darkBlue); keywordFormat.setFontWeight(QFont::Bold); QStringList keywordPatterns; keywor...

C++ Structure within itself?

I've been trying to port this code to python, but there is something I do not quite understand in C++ (I do know a bit of C++ but this is beyond me): typedef struct huffnode_s { struct huffnode_s *zero; struct huffnode_s *one; unsigned char val; float freq; } huffnode_t; What I don't get is how huffnode_s can be within...

Custom URL protocol in Windows to serve HTML content

This question addresses how to register a custom URL protocol to launch an application in response to a link, but I want my handler to serve dynamic content. Essentially, I'm looking to create a web application that runs on the user's machine instead of a web server. I could set up a localhost, but I want to use a "friendly" URL format...

C++ template name pretty print

hello. I have need to print indented template names for debugging purposes. For example, instead of single-line, I would like to indent name like this: boost::phoenix::actor< boost::phoenix::composite< boost::phoenix::less_eval, boost::fusion::vector< boost::phoenix::argument<0>, boost::phoenix::argument<...

Difficulties getting GraphViz working as a library in C++

Am working on a program that will allow a graph of nodes to be displayed and then updated visually as the nodes themselves are updated. I am fairly new to Visual Studio 2010 and am following the GraphViz guide located at http://www.graphviz.org/pdf/libguide.pdf in order to get GraphViz working as a library. I have the following code whic...

Where is a good place for a code review?

Hi, all! A few colleagues and I created a simple packet capturing application based on libpcap, GTK+ and sqlite as a project for a Networks Engineering course at our university. While it (mostly) works, I am trying to improve my programming skills and would appreciate it if members of the community could look at what we've put together....

Which logging library to use for cross-language (Java, C++, Python) system

I have a system where a central Java controller launches analysis processes, which may be written in C++, Java, or Python (mostly they are C++). All these processes currently run on the same server. What are you suggestions to Create a central log to which all processes can write to What if in the future I push some processes to anothe...

Is there a Boost (or other common lib) type for matrices with string keys?

I have a dense matrix where the indices correspond to genes. While gene identifiers are often integers, they are not contiguous integers. They could be strings instead, too. I suppose I could use a boost sparse matrix of some sort with integer keys, and it wouldn't matter if they're contiguous. Or would this still occupy a great deal of...

Warping Images using cvWarpPerspective Results in Some Parts of the images out of the viewable area

Hi, I am trying to stich two images together. In order to do so I extracted sift features and find matches on the two images using this C implementation. http://web.engr.oregonstate.edu/~hess/index.html After that I found the homography matrix using the matched points. http://www.ics.forth.gr/~lourakis/homest/ But if I use this ...