c++

Where can I find a reference for the .vcproj file structure?

I looked on MSDN, couldn't find it. I found an XML Schema for the .vcproj file, which is nice. But what I really want is an explanation for each of the elements in the vcproj file, a reference. The immediate question in front of me is, what is the significance of the UniqueIdentifier attribute in the element VisualStudioProject/Files/Fi...

functions taking in two variables

Hello again, I have this question which I don't understand and need help here. 1) I have this function double covertD(double, int), which takes in two arguements and returns a double. It will have to convert between Fahrenheit and Celsius and vice versa. This conversion depends on the passed in integer value. Test case 1 If the p...

Binary Tree Node Fault

Here's the node definition: struct node{ int data; stuct node * left; struct node * right; }; What I am trying to do is list all the nodes that point to an ancestor node. After posting the wrong solution and taking advice from the answers, my new solution is: Recursively go through the binary tree. Add the current node to...

Forward-declaring template pointer

Do I really need three statements, i.e. like this class A; template<class _T> class B; typedef B<A> C; to forward-declare a pointer of template type C, like so: C* c = 0; I was hoping to be able to conceal the classes A and B in my forward-declaration, is that even possible? ...

Weird C++ templating issues

So basically the assignment was we had to create a doubly linked list that's templated generically instead of locked to a single data type. I've tried compiling both with gcc and msvc and both compilers are giving me roughly the same errors so I'm assuming its just my bad coding and not the quirkyness of one compiler or the other. Curr...

boost asio taking 100% cpu on read

Hi, i made a socket app that uses boost asio how ever it seems to take a lot of cpu when i try to read any thing from the socket. Atm i use a wrapper class so i dont have to expose the boost header files in my header file that looks something like this: class SocketHandle { public: SocketHandle() { m_pSocket = NULL; ...

How to get Linux distribution name and version?

In Windows I read the registry key SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName to get the full name and version of the OS. But in Linux, the code struct utsname ver; uname(&ver); retVal = ver.sysname; returns the string linux, not Ubuntu 9.04. How can I get the Linux distribution name and version? ...

explorer get image's thumbnail really fast, how does it work?

I am using explorer to view image in thumbnail mode. It is really fast to get thumbnail of each image(bmp, jpg). I am using the following code to generate thumbnails for each image. however it is much slower than the explorer, How can I write a part of code to generate thumbnail as fast as system and accurate(thumbnail generated by the ...

Ropes: what's "large enough to benefit from cache effects"?

From Wikipedia: The main disadvantages are greater overall space usage and slower indexing, both of which become more severe as the tree structure becomes larger and deeper. However, many practical applications of indexing involve only iteration over the string, which remains fast as long as the leaf nodes are large e...

How do you insert into a sorted linked list?

I just need to have a linked list in order by name. I can only get it as far as 1st, 3rd, 5th, .. nodes. I just can't think this far. I want to be a C++ programmer but if I can't understand this is their any hope? STL containers std::lists are not an option for me at this point as a student. What you see in the list function is what I am...

Boost::tuple's equivalent to Python's itemgetter?

I have some code that looks like this: typedef tuple<int, int, double> DataPoint; vector<DataPoint> data; vector<double> third_column_only; // Code to read in data goes here. transform(data.begin(), data.end(), back_inserter(values), tuples::get<1, DataPoint>); Unfortunately, the last line doesn't compile - it gives me a message like ...

processEvents And Memory Leak?

Hi all, NOTE: THE CODE PROVIDED JUST GIVES THE IDEA OF THE STRUCTURE OF THE APPLICATION I have a Qt application, interfacing with external hardware. The structure is such that the class for interfacing with the hardware inherits from QObject and is composed with the main GUI thread class. Let's say the class is test.h, here is its samp...

Image draw issue on Linux using Xlib

I am developing an application, in which I am receiving images from my window host.. the client side is in Linux using C++.. I am sending JPEG format from server side.. the problem I am facing is that when I receive the image on client, I use "XCreateImage" function to create the "XImage" and when I write this image to a file, it appears...

How to find the menu item (if any) which opens a given HMENU when activated?

I'd like to implement a function with the prototype /* Locates the menu item of the application which caused the given menu 'mnu' to * show up. * @return true if the given menu 'mnu' was opened by another menu item, false * if not. */ bool getParentMenuItem( HMENU mnu, HMENU *parentMenu, int *parentMenuIdx ); Given a HMENU handle,...

How to terminate a QThread?

QThread::terminate() states that it is discouraged to terminate a thread by calling this function. In my program, I need to terminate a thread before it finishes execution. The thread is performing some heavy computation and I want the user to have control to stop calculation. How can I do that instead of calling QThread::terminate()? T...

Why does Visual Studio 2008 highlight internal as a keyword in C++ code?

I'm porting VC++7 codebase to VC++9. Surprisingly Visual Studio 2008 highlights internal as a keyword in C++ code but looks like it is not really treated as such. What is this - a bug in VS, an environment setting I haven't found yet, or a sign that I will no longer be allowed to use internal as a regular identifier in some upcoming ver...

Object layout in case of virtual functions and multiple inheritance

Hi, I was recently asked in an interview about object layout with virtual functions and multiple inheritance involved. I explained it in context of how it is implemented without multiple inheritance involved (i.e. how the compiler generated the virtual table, insert a secret pointer to the virtual table in each object and so on). It see...

Convert String containing several numbers into integers

I realize that this question may have been asked several times in the past, but I am going to continue regardless. I have a program that is going to get a string of numbers from keyboard input. The numbers will always be in the form "66 33 9" Essentially, every number is separated with a space, and the user input will always contain a d...

About the MFC CFileDialog Problem

About the following code, it is written by MFC, but in test time, i run the simple program, i will not got a normal case, the program will return a failed message to me, the message is "Can't play file:[PATH]". but if me fixed the File (not select form the the dialog), it is work, i can not find out the problem, i hope some people can h...

Linux LiveCD for software developers

Hi all, My primary development platform is Windows, however I sometimes need access to Linux for porting and testing my apps. To do so I use a preconfigured general purpose VMware image. However I'm looking for a simpler, more light-weight solution. I'm thinking about a zero-installation LiveCD dedicated to software development, booted ...