c++

QImage from datastream

I'm using the Qt library, creating QImages. I'm able to use this constructor: QImage image("example.jpg"); But I'm having trouble with this static function: char buffer[sizeOfFile]; ifstream inFile("example.jpg"); inFile.read(buffer, sizeOfFile); QImage image = QImage::fromData(buffer); // error here // but there's nothing wrong wit...

intellisense for previously declared varibles and constants

I am using MSVS C++ Express 2008. Right now my intellisense only works for objects that have methods or arguments in a method. Is it possible to set it where it detects declared constants and varibles that are within scope. Thanks ...

Any memory usage paradigm besides Stack and Heap?

As I have learned data structure, I know there are plenty of other data stuctures besides Stack and Heap, why the processes nowadays only contain these 2 paradigm as the "standard equipment" in their address space? Could there be any brand new paradigm for memory usage? Thanks for your replies. Yes, I realized that something is wrong wi...

how do i send keystrokes to only one program?

i have been having a hard time to find anything that is usefull but i found someone asked how to do that,(http://stackoverflow.com/questions/2113950/how-to-send-keystrokes-to-a-window) if used the code and i can set notepad's text but i want to send keys but sets the text, i want to send keys like keybd_event i have been using it but i ...

How can I slow down a TCP connection on Windows?

I am developing a Windows proxy program where two TCP sockets, connected through different adapters are bridged by my program. That is, my program reads from one socket and writes to the other, and vice versa. Each socket is handled by its own thread. When one socket reads data it is queued for the other socket to write it. The probl...

Building a suffix tree in C++

I'm attempting to build a suffix tree in C++ as part of an assignment on gene sequencing void Tree::insert(string ins) { Node* iterator = chooseBranch(root, ins.at(0)); string temp; for(int i=0; i<100; i++) { if(iterator->data=="") . . . chooseBranch() is a function to pick which of 4 children to go to, a...

Is 'using namespace std;' a standard C++ function?

Is using namespace std; a standard C++ function? ...

return value of prefix and postfix in C++

Why in C++ the prefix return a reference but the postfix return a value? ...

XPCOM C++: Does it support RegExps?

I'm developing a XPCOM C++ component that have to use some RegExps functions Does XPCOM C++ have build-in support for RegExps? ...

What are real-world examples of C++ multiple inheritance?

Besides textbook examples -- in the real world -- does it ever make sense to use multiple inheritance (where more than one of the base classes are not pure interfaces) in C++? ...

Is There any Following C++ Blocking Condition Variable

I would like the have the following Blocking Condition Variable Once the blocking condition variable had been signaled, all threads will not wait on the particular condition variable The condition variable can be unsignaled anytime. Once condition variable had been unsignaled, all threads will be waiting on the variable I look at ht...

C++ multiple inheritance preventing diamond

Is there a way to define a class Foo in C++ so that I can inherit from it I can't "diamond inherit" from it I.e. class Cat: public Foo{} // okay class Dog: public Foo{} // okay class Weird: public Cat, public Dog {} // I want this to throw a compiler error ...

Should I put global application details in a static class?

I'm currently maintaining a legacy C++ application which has put all the global application details in a static class, some of the variables stored are: application name registry path version number company name etc.. What is the recommended method for storing and accessing system application details? ...

qtreewidgetitem addchild to already present item yields nothing

I have two QTreeWidgetItem that are top level. I want to make the second the parent of the first. Calling the first one's addChild(second item) shows no change. How would I accomplish this? ...

Using SetKeyboardState along with GetKeyboardState in C++

I don't know how to write a good question here, but, basically, does anyone know where I can possibly find some C++ source code using these to actually set keyboard state? For some reason using it the way MSDN does on Windows 7 doesn't do...anything at all. Basic code: PBYTE keyState; GetKeyboardState(keyState); ... // Later on whe...

Directx9 Specular Mapping

How would I implement loading a texture to be used as a specular map for a piece of geometry and rendering it in Directx9 using C++? Are there any tutorials or basic examples I can refer to? ...

How do I fix this formula error?

I have this code in my program: (I included the cout statements for debugging purposes) cout << "b: " << b << "\na: " << a; constant[0] = (-b / (2 * a)); cout << "\nconstant: " << constant[0] << endl; The output I get is: b: -4 a: 3 constant: 0 Whereas I'm trying to make constant[0] equal to -(-4)/(2 * 3), or 0.6666... What am I do...

Opening fstream with file with Unicode file name under Windows using non-MSVC compiler

Hello, I need to open a file as std::fstream (or actually any other std::ostream) when file name is "Unicode" file name. Under MSVC I have non-standard extension std::fstream::open(wchar_t const *,...)? What can I do with other compilers like GCC (most important) and probably Borland compiler. I know that CRTL provides _wfopen but it ...

MSVC Dependencies vs. References

I have always used the Visual Studio Dependencies option to ensure that, for example, when building my C++ projects, any dependent LIB or DLL projects are also built. However, I keep hearing people mention 'references' and wondered, with VS 2010 on the horizon, I should be changing how I do this. Are there any benefits to using referen...

How to convert UNC to local path

I'm looking for a method to get corresponding local path for a given UNC path. Microsoft provides a small library CheckLCL for this purpose. This library is not supported on all Windows versions. Does anybody know any open source method for this? There is also MAPI function ScLocalPathFromUNC, but am not sure if it works on all platfor...