c++

Adding folders to the sidebar of a CFileDialog

Is there any way to add folders to the sidebar in an MFC CFileDialog? (You know, the bar with shortcuts to "Recent Documents", "My Documents", etc. on the left side of the dialog.) Note that I do not mean that I want the user to have to hack the registry or something to permanently add folders to the sidebar system-wide, I'm talking abou...

shared_ptr with templates

Hello! If I want to create a smart pointer to struct I do that: struct A { int value; }; typedef boost::shared_ptr<A> A_Ptr; So, I can write the following: A_Ptr pA0(new A); pA0->value = 123; But, If I have a template struct like that: template<typename T> struct B { T value; }; And I want to write the following: ...

Determine thread which holds the lock on file

Hi, I know there is no WINAPI which would do it, but if a thread is hung and holds an open handle of file. how do we determine the thread id and Terminate it within our processes. I'm not talking about releasing file locks in other processes but within my own process. it could also be possible that thread has crashed / terminated with...

How to add a .o on a static library with Eclipse ?

I have a .h and a .o that I need to add to a static library in Eclipse. I'm able to add it to an application with the Linker options, but for a static library, I haven't found where to add it in the settings. ...

Convert files of any types to a file with c strings.

Please suggest a small command-line utility (for Windows) to convert files from particular directory to a valid c file. Maybe it can be done just with batch commands? The resulting file should look like this: static const unsigned char some_file[] = { /* some_file.html */ 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x7...

String in scientific notation C++ to double conversion

Hi, I've got a database filled up with doubles like the following one: 1.60000000000000000000000000000000000e+01 Does anybody know how to convert a number like that to a double in C++? Is there a "standard" way to do this type of things? Or do I have to roll my own function? Right now I'm doing sth like this: #include <string> #in...

Know any good c++ support vector machine (SVM) libraries ?

Hey everyone, Do you know of any good c++ svm libraries out there ? I tried libsvm (http://www.csie.ntu.edu.tw/~cjlin/libsvm/) but so far I'm not flabbergasted (no documentation, or close to none). I have also heard of SVMLight and TinySVM. Have you tried them ? Any new players ? Thanks ! JC ...

C#: problem loading C++ DLL

In my code, I can load "MessageBoxA" from user32.dll and use it, but if I try to load and use a function from my DLL, I get a crash. My C# code: [DllImport("SimpleDLL.dll")] static extern int mymean(int a, int b, int c); [DllImport("user32.dll")] static extern int MessageBoxA(int hWnd, string msg, ...

sizeof(*this) in header only constructor implementation

The title says it all, and whilst the 'standards' are to prefer a sizeof(typename), are there any instances where the sizeof(*this) is more error-prone or somehow undesirable? I cannot see any at the first glance, but if yes, why with a short explanation would be helpful. Thanks. ...

Destructor of a concrete class

Guideline #4 link text, states: A base class destructor should be either public and virtual, or protected and nonvirtual. Probably I'm missing something, but what if I just create a concrete class, that is not designed to be used as base class. Should I declare it's destructor public and virtual? By this I'm implicitly declate...

How can I read and parse a URL's XML or JSON content with C++?

I can easily do this with JQuery or PHP but I have a project for my Intro to C++ class and I thought it'll be pretty cool if I could mix C++ with some APIs like twitter, google, yahoo etc. Could you tell me if there is a class ( I know OOP ) I can use to read an external XML or JSON file. The program has to run on windows and linux so I...

QT exited with code 0 on release

Hello, Does anyone have stucked on strange problem with QT Creator. When I try to build my simple console app in it with release in output window i see only: Starting C:\Users\xxxxx\Documents\Composite\Compositing\debug\Compositing.exe... C:\Users\xxxx\Documents\Composite\Compositing\debug\Compositing.exe exited with code 0...

Design methods for multiple serialization targets/formats (not versions)

Whether as members, whether perhaps static, separate namespaces, via friend-s, via overloads even, or any other C++ language feature... When facing the problem of supporting multiple/varying formats, maybe protocols or any other kind of targets for your types, what was the most flexible and maintainable approach? Were there any conven...

Returning a C++ class to Java via JNI

Hello, I'm currently using both C++ and Java in a project and I'd like to be able to send an object which is contained in C++ to my Java interface in order to modify it via a GUI and then send the modification back in C++. So far I've been returning either nothing, an int or a boolean to Java via the JNI interface. This time I have to ...

Why this program fails (sometimes)?

#include <cstdio> #include <QtCore/QProcess> int main (int argc, char** argv) { // if we remove 3 following lines, the problem described below doesn't exists!! QProcess process; process.start ("asdqwe"); // doesn't matter what we try to execute here. process.waitForStarted (1000); while (true) { char buf[100]; if (sca...

Initialising classes inside another class in C++?

I have this definition in a header file: class Owner { private: // Fields Child* _myChild1; public: // Constructors Owner(); Owner(const char childName[]); }; and this implementation: Owner::Owner(const char childName[]) { //do some operations - children must be created after these ops _myChild = new Child(childName); } and th...

Does anyone know where I can find the standard windows file dialog toolbar icons?

I'm trying to roll my own implementation of IShellBrowser because I need to have a more full-featured File Open and Save As dialog than Windows allows that is compatible with XP (and ideally with W2000)* At this point I need to add the standard toolbar that you see in upper right of the dialog (manifest styles for XP and earlier) - a ba...

How to store state on a node for a visitor pattern?

I have an architecture that uses the visitor pattern to implement a number of passes over a tree (an AST as it happens). In one of the passes I need to associate some data with a node (nodeX) and then from some point below it get my data from a reference to the nodeX. I want to do this in a way that doesn't push the implementation of the...

What is this weird colon-member syntax in the constructor?

Recently I've seen an example like the following: #include <iostream> class Foo { public: int bar; Foo(int num): bar(num) {}; }; int main(void) { std::cout << (new Foo(42))->bar << std::endl; return 0; } What does this strange : bar(num) mean? It somehow seems to initialize the member variable but I've never seen this syntax...

Binary Search Tree Array Imp. C++

Hello, I'm just having trouble with Inserting into the array...And having the children branch off from the root, or "parent".. I've been trying to insert data into an array based implementation of a BST: BST::BST(int capacity) : items(new item[capacity]), size(0) { // define the constructor to the BST Class. } void BST::insert (...