c++

Why is the "this" pointer in c++ a pointer and not a reference?

Possible Duplicate: Why this is a pointer and not a reference? Are there use-cases that I'm missing that make "this" as a pointer more useful than a reference? If not, are there any language design implications/considerations involved in having it as a pointer? Thank you. ...

How can I handle packed data from Perl/PHP in C++?

I got a problem implementing a PHP programm in C++. It is about the PHP/Perl function unpack. I don't know how to do the follwing in C++ (no problem in reading a file... but how do i unpack("C*") the read contents). <?php $file = fopen("bitmaskt.dat", "rb"); //create the data stream $matrix_x = unpack("C*", fread($file, 286));...

WinAPI for Game Controllers

Hi there! I know that all windows platforms automatically detect when a game controller is connected. I also know there is a WinAPI for polling these controllers. I can't seem to find the functions I am looking for anywhere. Any help is greatly appreciated! Brendan ...

C++ pointer help

#include <iostream> using namespace std; struct InvRec { int PartID; float Price; int Warehouse; }; typedef InvRec *InvRecptr; typedef InvRec arr[]; typedef InvRecptr * indexarr; void deallocate (indexarr & ptrs, int & size) { for (int i=0; i<size;...

hooking on WM_SETTEXT message

I have setup a hook on WM_SETTEXT message using WH_CALLWNDPROC. In hook procedure CWPSTRUCT* info = (CWPSTRUCT*) lParam; switch(info->message) { case WM_SETTEXT: break; } Now in the above code how can I get the string that is passed along WM_SETTEXT message? I am not able to get this information anywher.. ...

How can I display variable strings using C++ and PDCurses?

I'm extremely sorry to post such an embarrassingly newbish question, but I haven't mucked around much with C++ since my college days and I think at some point I drank all that I knew about pointers and C++ strings right out of my head. Basically, I'm creating a C++ console app (a roguelike, to be precise) with PDCurses to handle output....

API to use deault Web Cam?

I'm working on a Win32 application in C++ and would like to add the ability to output the default web cam onto the screen. I was wondering if there was a Win32 API for this, or a way to do this without coding the whole thing. Thanks ...

Changing string after hooking WM_SETTEXT

I have setup a hook on WM_SETTEXT message using WH_CALLWNDPROC. In hook procedure CWPSTRUCT* info = (CWPSTRUCT*) lParam; wchar_t *wsz = NULL; switch(info->message) { case WM_SETTEXT: wsz = (wchar_t *) info->lParam; //info->lParam = (LPARAM) L"Hello"; //SendMessage(info->hWnd,WM_SETTEXT,0,(LPARAM)L"HEllo"); //SetWindowText(info->hWnd,L"...

Installing C/C++ libraries on Windows

I'm studying (well, trying to) C right now, but I'm limited to working in Windows XP. I've managed to set up and learn how to use Emacs and can compile simple C programs with gcc (from Emacs no less!), but I'm getting to the point where I'd like to install something like SDL to play around with it. The thing is that the installation in...

Static variables in instance methods

Let's say I have this program: class Foo { public: unsigned int bar () { static unsigned int counter = 0; return counter++; } }; int main () { Foo a; Foo b; } (Of course this example makes no sense since I'd obviously declare "counter" as a private attribute, but it's just to illustrate the problem). ...

Compiling OpenCV for Visual C++ 9.0

I looked at many places but could not find anything telling me how to buld the lib files. I know how to link them, but openCV install folder only contains .a files. I cant find an sln file or dsp. How can I make the lib files? Right now all the samples get linker problems because the lib files dont exist. Thanks ...

am i implementing this template class correctly?

Okay, I'm trying to implement a templated class of an array-based queue called Queue. Here's how I did it. First, is this the right way to implement a templated class? The problem is, when I try to compile, I get the error messages undefined reference to 'Queue::Queue()' undefined reference to 'Queue::~Queue()' Any ideas what...

Algorithm for searching for an image in another image. (Collage)

Is this even possible? I have one huge image, 80mb with a lot of tiny pictures. They are tilted and turned around as well. How can i search for an image with programming? I know how to use java and c++. How would you go about this? ...

A scripting language to simply compile

I'm looking for a simple script language which I can compile easily by just putting the .h files under an include folder and the .c/.cpp files under a source directory. Something without any Makefile. Must be written in C/C++ rather C++. ...

Counter in AS3 "without dynamic text field"

What is the best way to program an LED number tick. I need to have a number display that goes up to 1,000,000.00. Dynamic text fields are not an option because of symbol instances. How would I make a counter? ANIMATION The numbers move in increments like an LED display. This NUMBERS The numbers multiple by ten each space over decima...

Program Interaction and testing via bash script

I've just completed the coding section of simple homework assignment for my C++ class. The second part of the assignment requires us to verify our code's input validation. (The program takes several different values as inputs from a user and prints those values to a file) I was hoping that I could use bash script for this. Is there a...

Calculating a gradient fill's start and end colours given a base colour

I have a WTL C++ application and I want the user to be able to select different colours for some of the UI elements and apply a gradient fill using the GradientFill API call. However, instead of letting the user pick the start and end colours for the gradient, I'd like them to be able to select a 'base' colour and for my application to ...

too few template-parameter-lists with stlport in Android-NDK

When trying to compile some c++ code with the Android-ndk in cygwin i keep getting the error" error: too few template-parameter-lists" many times. I am not sure if using the STLport would have an influence on this error but i have that installed as well. I doubt this had anything to do with the problem because i am pretty sure i was gett...

Collisions in a real world application.

Here's my problem. I'm creating a game and I'm wondering about how to do the collisions. I have several case to analyze and to find the best solution for. I'll say it beforehand, I'm not using any third party physics library, but I'm gonna do it in house. (as this is an educational project, I don't have schedules and I want to learn) ...

Explicitly exporting shared library functions in Linux

Is there a Linux equivalent of __declspec(dllexport) notation for explicitly exporting a function from a shared library? For some reason with the toolchain I'm using, functions that aren't class members don't appear in the resulting shared library file. ...