c++

In Qt, how do I query the state of a QMutex or a QReadWriteLock?

Hi, I'm using a QReadWriteLock in my application to guard access to a resource object. I'm using QReadLocks and QWriteLocks where I can, but sometimes I need a "long-lived" lock that crosses function boundaries. So sometimes I need to be able to query the state of the QReadWriteLock (or QMutex, same thing in this situation) because unl...

C++: How to make constructor for multidimensional vector?

I want to create two and three dimensional vectors using a constructor in a class. However, I do not know how for multidimensional vectors. One dimensional works: class One{ public: vector < float > myvector; One(int length) : myvector(length){} }; Two dimensional does not work: class Two{ public: v...

"as if" in language standards

What is the exact meaning of the phrase "as if" in standards and how does it work when a user can modify individual parts of the behavior. The question is in regards to the C++ standard when talking about the nothrow version of operator new. 18.4.1.1/7 reads (my emphasis): This nothrow version of operator new returns a pointer obta...

gstreamer: interleaving 2 audios - link error

hi, I am trying to interleave two audio files as given in the interleave GStreamer documentation: gst-launch interleave name=i ! audioconvert ! wavenc ! filesink location=file.wav filesrc location=file1.wav ! \ decodebin ! audioconvert ! "audio/x-raw-int,channels=1" ! queue ! i.sink0 filesrc location=file2.wav ! \ decodebin ! audio...

Using boost::optional with constant types - C++

I have a container class which uses boost::optional to hold the value. Here is the code looks like, template<typename T> struct traits { typedef T value_type; typedef T& reference; }; template<typename T> struct traits<const T> { typedef const T value_type; typedef const T& reference; }; template<typename T> struct t...

Find the biggest rectangular area consisting only of 2 types of letter in a given MxN board.

Possible duplicate: http://stackoverflow.com/questions/2301733 I need help with a problem. Given a MxN board represented with M letters (a-z) in each of the N lines, i have to find the biggest area in which there are only 2 types of letters in it. The area must have rectangular shape. Here's an example : 4x4: AAAA ABBC BBCA DCAA ...

advanced c or c++ book

what is the most advanced c or c++ book you ever read? i am asking this because i already read lots and lots of books on c and c++ on a lot of topics including (object oriented programming-data structures and algorithms-network programming-parallel programming (MPI-PThreads-OpenMP-Cilk-Cuda)-boost library....). So whats next. I still wan...

Is there any way to decompile Linux .so?

Is there any way to decompile Linux .so? ...

Is there an alternative to HTML Tidy?

Hi, I have embedded HTML Tidy in my application to clean incoming HTML. But Tidy has a huge amount of bugs and fixing them directly in the source is my worst nightmare. Tidy source code is an unreadable abomination. Thousand+ line functions, poor variable naming, spaghetti code etc. It's truly horrible. Worse yet, official development ...

Drag and Drop like Winspector Spy

I was wondering if anybody could give insight on how to implement the window selector in Winspector Spy. Basically, I would want to provide a panel that I could mouse down on, drag over to another processes window (or sub window) and get something like the HWND out of it. Ideally, I would do this in C#, but if it's only possible by wra...

Stack Overflow Error With This Recursive Program? - C++

Hello, I'm a programming student in my first C++ class, and recently we were given an assignment to implement a recursive program that finds the first occurrence of a given substring in a given string. For example: int StringIndex("Mississippi", "sip"); // this would return 6 The hint we are given is to use a recursive helper functi...

How can I concisely initialize a safe collection in C++?

Possible Duplicate: C++: Easiest way to initialize an STL vector with hardcoded elements I'm learning C++ right now, and I'm looking for a way to quickly and easily initialize a "safe" collection (like a vector) with different values for each element. I'm accustomed to Python's concise list/tuple initializations, and I want to...

How to print string C++ mfc

Hi all I created project using VS2008 wizard SDI > CView How can i print some text from Cstring to my main window CView for example in dialog window with list box i use smth like this m_ListBox1.AddString((LPCTSTR)s); ...

Qt widget disobeys drop in Windows

I have a Qt 4.6 based app that is compiled on both a Linux machine and Windows machine. I have two widgets: 1. allowdrop=false and drop type is internal only 2. allowdrop=false and drop type is no drag and drop On the linux machine, dragging the first control's items to seconds does nothing and even shows the "no" symbol for not allow...

Reading variable length user input in C++

How do I read in a variable number of characters? The user can input a positive or negative number that is too big to be stored in an integer. I am then checking to make sure the char is a number and storing it in an array of ints (although that will probably be changed to a short since I only need to be able to store 0-9). istream& op...

Enable AntiAliasing in Direct3D9 (MultiSample Render Target)

I am trying to enable AA in a D3D9 application, but am not sure how to set up the surfaces correctly. So far, I have: IDirect3DDevice9* m_pd3dDevice; IDirect3DSurface9* screen; IDirect3DSurface9* msaasurf; D3DPRESENT_PARAMETERS m_presentationParameters; Initialization: m_presentationParameters.Windowed = TRUE; m_presentationParameter...

Does getting random SIGTRAP signals (in MinGW-gdb) is a sign of memory corruption?

I wrote my own reference counted memory manager c++ (for fun) and I'm sure it isn't perfect ;) . And now when I'm trying to use it I got random SIGTRAP signals. If I comment out every line which are in connection with that memory manager everything runs fine. Getting SIGTRAP-s instead of SIGSEGV is quite strange. I know that SIGTRAP-s ar...

C++ Beginner's question on input/output text files.?

If I have an input text with the only thing written of "A" and I want a series of code that will allow me to generate the next ASCII set (B), how would I do so? #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { return 0; } #include iostream> #include fstream> #include iomanip> #include string> using namespace std; int ...

Segmentation Fault when outputting in C++

I am trying to print out an array of integers. I am getting a seg fault when I try to print as below. If I uncomment the "In for loop" it will print everything except the last item of the array and it still has a seg fault. When I uncomment both of the comments (or just the "done with for loop") everything prints fine. Why does this happ...

C++ Linker Error involving operator overload function

I have a List of type Node. I want to set a temporary Node equal to the Node at the front of the List but I keep getting a Linker Error: class Node { public: Node(); Node& operator = (const Node& n); }; 1>Linking... 1>main.obj : error LNK2019: unresolved external symbol "public: class Node & __thiscall Node::operator=(...