c++

GetKeyState doesn't work in Windows 2000 (C++)

Hello. I have just tested my DirectX game on a Windows 2000 SP4 system but it won't receive any mouse clicks! This is how I check for mouse clicks : unsigned int mButtons = 0; if (GetKeyState(VK_LBUTTON) < 0) mButtons |= HIDBoss::MOUSE_LEFT; if (GetKeyState(VK_RBUTTON) < 0) mButtons |= HIDBoss::MOUSE_RIGHT; if (GetKeySt...

How to get started with parsing network streams in c++?

I'm having hard time getting started with this, can you provide learning resources,hello world demos,or tips? ...

store data dynamically coming from database - c++

hi, Can you give me a idea about the best way that can i store the data coming from the database dynamically. I know the number of columns before, so i want to create a data structure dynamically that will hold all the data, and i need to reorganize the data to show output. In one word - when we type the query "select * from table" - re...

How to combine templates with enums in C++?

There are a huge feature collection in C++ programming language that supply a strict control over datatypes. Frequently one would mold his code with template system to achieve the most adequate functionality while guaranteeing within it correct type preservation and flexibility in its manipulation. Less frequently enumerations are used f...

Copy Constructor with reference variable

I have a class as given below, I want to write a copy constructor for the same. I need to create a deep copy constructor for this. following code is printing x and c properly but value of y here is garbage. #include "stdafx.h" #include <string.h> class MyClass { public: MyClass(int a) : y(a) { } MyClass(const MyClass &myClass) : y(...

Qt widget based on QWidget

Hello, I try to create my own widget based in QWidget. In constructor of the class i have: Square(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); Square::Square(QWidget *parent = 0, const char *name = 0, WFlags fl) : QWidget(parent, name, f) { if (!name) setName("Game"); reset(); ...

how to read lua table return value from c++

hi, I have a lua function that returns table (contains set of strings) the function run fine using this code: lua_pushstring (lua, "funcname"); lua_gettable (lua, LUA_GLOBALSINDEX); lua_pushstring(lua, "someparam"); lua_pcall (lua, 1, 1, 0); the function returns a table. how do I read it's contents from my c++ code? ...

Creating a transparent window in C++ Win32

I'm creating what should be a very simple Win32 C++ app who's sole purpose it to ONLY display a semi-transparent PNG. The window shouldn't have any chrome, and all the opacity should be controlled in the PNG itself. My problem is that the window doesn't repaint when the content under the window changes, so the transparent areas of the P...

Displaying log data in latest-first format

I like having log data in a last-first form (the same way most blogs and news sites organize their posts). The languages I'm most comfortable in are C++ and Python: is there a way to output log data either to the screen (stdout) or a file with the most recent entry always being on top? Or is there perhaps a way of modifying tail to sho...

What is the point of a private pure virtual function?

I came across the following code in a header file: class Engine { public: void SetState( int var, bool val ); { SetStateBool( int var, bool val ); } void SetState( int var, int val ); { SetStateInt( int var, int val ); } private: virtual void SetStateBool(int var, bool val ) = 0; virtual void SetStateInt...

populate c++ maps content in a loop scope

I try to populate the content of a c++ map within a loop scope. #include <set> #include <map> map<int, set<int> > maps; for (int i=0; i<10; i++) { set<int> seti; // content: a set of integers seti.insert(i); seti.insert(...); maps.insert ( pair<int,set<int> >(i,seti) ); } The question is: does maps.insert copy the pa...

Fedora Equivalent of prstat /truss

Is there any command in Fedora core (10) which displays the system call being executed ? Scouring the internet only reveals top and likes... ...

Neural Networks: Minimal, open source example with exhaustive training data?

Hello forum, I am currently searching for a neural network (toy) example, that I might optimize using GPU kernels. I need clean & minimal code (no fancy optimizations, max. a few thousand sloc) ample testing data C/C++ open source Does anybody has an adequate hint? There's a bunch of examples on the net, but with insufficient test...

What is object index of QTextFormat?

The function int QTextFormat::objectIndex () const returnes an object index. What is it? And what if I do the following: QTextBlockFormat bfmt; bfmt.setObjectIndex(0); What this code does? ADDED: Here there is a function void TextEdit::textStyle(int styleIndex). This function is for adding a list into QTextEdit, or making it ...

What’s the best way to delete boost::thread object right after its work is complete?

I create boost::thread object with a new operator and continue without waiting this thread to finish its work: void do_work() { // perform some i/o work } boost::thread *thread = new boost::thread(&do_work); I guess, it’s necessary to delete thread when the work is done. What’s the best way to this without explicitly waiting for ...

STL Set: insert two million ordered numbers in the most efficient manner

For the following mass-insert, because the inputs are ordered, are there any (slight) optimizations? set<int> primes; for ( int i = 2; i <= 2000000; i++ ) { primes.insert(i); } // then follows Sieve of Eratosthenes algorithm New improvement, twice as fast: set<int> primes; for ( int i = 2; i <= 2000000; i++ ) { primes.inser...

What's the C++ version of Java's ArrayList

Just getting back into using C++ and trying to convert a simple Java program I wrote recently. What's the preferred equivalent to the Java ArrayList in C++? ...

How does a bit field work with character types?

struct stats { char top : 1; char bottom : 1; char side : 2; } MyStat; I have seen this format with integers but how does the above char bit field work and what does it represent? Thank You. ...

how to call an operator as function in C++

Hello, I want to call a specific operator of specific base class of some class. For simple functions it's easy: I just write SpecificBaseClass::function( args );. How should I implement the same for operators without casting trickery? Isolated problem: class A { public: A operator+( const A &other ) const {...} }; class B :...

Weird behaviour with sockets on localhost

I have two .net applications communicating with sockets on port 5672 and everthing works fine. On server side, i open the connection with this simple code lines: IPAddress localAddr = Dns.GetHostEntry("localhost").AddressList[0]; TcpListener socket = new TcpListener(localAddr, 5672); socket.Start(); If i try to launch another...