c++

When to Return a Recursive Function?

I have a question on return and recursive functions. This is again based off of a binary Tree which I am currently working on. The code is void Tree::display() { if( !root_ ) return; display_r(root_); } void Tree::display_r(Tree *node) { if( 0 == node ) return; display_r(node->left_); std::cout <<...

Passing a struct with multiple entries in c++

I am trying to pass a coordinate, which is defined as struct with 2 integer parameters (the struct is called coord) the following way: UpdateB({0,0}); where the input argument is of type coord (i.e. in the above statement I am trying to pass a coordinate 0,0). UpdateB is some function. I am getting an error, any ideas what the probl...

C++ looking for String.Replace()

Hello i have a a char array in C++ which looke like {'a','b','c',0,0,0,0} now im wrting it to a stream and i want it to appear like "abc " with four spaces insted of the null's i'm mostly using std::stiring and i also have boost. how can i do it in C++ basicly i think im looking for something like char hellishCString[7] = {'a','b'...

When embedding Java in a C++ application, which files do I need to take?

Our C++ application hosts Sun's JVM and I need to upgrade it to the newest version on Windows. I downloaded JDK 6u20, but I have no idea which folders to take into our installation. We currently have some version of Java 5 but it seems that whoever did it in the first place, cherry picked the files. I'd like to know which folders to tak...

parse variable from php to a c++ function as an argument

I have a web server which receives an image from a client and do some SIFT based image matching at the server (win32) end send the result back to the client. Receiving image is done using apache and php. SIFT based processing functions are in C++. Now I want to parse the data in php variable $image (the variable which holds the received...

How to find floppy\ CD sector size in Linux?

Hi, How can I get the sector size for floppy and CD disks in Linux, via C++ code? Thank you all. ...

Computational cost

Is there someone that knows what is the computational cost for this two piece of code? while(n>2) n = sqrt(n); while(n>2) n = log(n) ...

How are circular #includes resolved?

In c lets say we have 2 files 1.h #include<2.h> blah blah and we have 2.h #include<1.h> code How is this resolved?? ...

Add a custom tool to toolchain to remove UTF-8 BOM before compile

My question is in the context of Code::Blocks and its tweaked version of MinGW, and Notepad++ . I want to be able to include Unicode literals in my source, and I can, so long as I use UTF-8 and not use a BOM. This works fine, up to a point, but it BOMs out (bad pun) whenever I reopen the file; it (not surprisingly) has this un-nerving ...

Qt: delegate to a single editor

What im trying to do is have a table which does not appear editable directly but can be edited in some widget outside the table. That is, the selected node can be edited here, and all nodes use the same editor because i want it to always be shown. What I've tried is to subclass QItemDelegate and just return the instance of QTextEdit i a...

How to get MRU List data?

Hi, how can i get data prgogrammaticaly from windows registry MRU list? I am using vc++. For example windows xp search history is located in Software\Microsoft\Search Assistant\ACMru\5603. How can i get data from it? EDIT:I still dont know howto do this, can you be more specific? So what steps do i need to do to have acess to data? ...

Error with bc++ and glut

hey guys This code compiles fine in Vc++ but in borland c++ gives me this error.. Please help me out.. The code has no syntax errors and works fine.. Seems like there is a problem with the header.. But these are the standard headers and library files Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland main.c: Error E2337 c:\Bor...

Qt - Get rid from .dll file missing errors.

I have created a GUI which requires .dll files in order to work. Here the list of those: mingwm10.dll libgcc_s_dw2-1.dll QtCore4.dll QtGui4.dll I have read that I should write CONFIG += static in .pro file. But it does not work. Could you help? ...

Qt - Esc should not close the dialog.

How to make Esc key to minimize a dialog? By default it closes. Should I process KeyEvent or there is a better way? ...

boost::serialization deserializing xml_archive exception

Hello StackOverflow! im trying to serialize some object as xml and then read it back the code is: IncomingTradeMessage inherits BaseMessage and contains InternalRequestInfo which in turn contains InternalTradeTransInfo. this is the code: std::ostringstream oStringStream; boost::archive::xml_oarchive xmlArchive(oStringStream); xmlArch...

Returning char* / Visual Studio debugger weirdness

We're getting some funny behavior in the Visual Studio debugger with the following. I'm not sure if it's the code or some debugger weirdness (seen stuff like it before). We are trying to return a pointer to an value in an array. The weird behavior is that the value of x changes to equal y after func() is called a second time...at least,...

How do C++ class members get initialized if I don't do it explicitly?

Suppose I have a class with private memebers ptr, name, pname, rname, crname and age. What happens if I don't initialize them myself? Here is an example: class Example { private: int *ptr; string name; string *pname; string &rname; const string &crname; int age; public: E...

libxml2 crash on second use on Windows

Hi, I've been using libxml2 push parsing (SAX) to parse an incoming XML stream, this works well first time but crashes on the second attempt every time, my code looks like this: xmlSAXHandler saxHandler; memset(&saxHandler, 0, sizeof(m_SaxHandler)); xmlSAXVersion(&saxHandler, 2); saxHandler.initialized = XML_SAX2_MAGIC; // so we do th...

Except OOP, what is making C++ better than C

Well that may sound like a troll question, but since C++ seems hard to fully master (and I never really knew STL was actually "part" of it), I wanted to know what are the disadvantages to use C instead of C++ when not relying much on OOP. C++ can have a very much sophisticated syntax sometimes, which is kinda confusing me while trying t...

How to programmaticaly get windows search history?

Hi, how can i get the windows search history and use it in my program? For example i write ".doc" in windows search bar. Now i want in my program to find out from somewhere, that i searched for ".doc" in my system(not web). How can i do this? ...