c++

Boost: what could be the reasons for a crash in boost::slot<>::~slot ?

I am getting such a crash: #0 0x90b05955 in __gnu_debug::_Safe_iterator_base::_M_detach #1 0x90b059ce in __gnu_debug::_Safe_iterator_base::_M_attach #2 0x90b05afa in __gnu_debug::_Safe_sequence_base::_M_detach_all #3 0x000bc54f in __gnu_debug::_Safe_sequence_base::~_Safe_sequence_base at safe_base.h:170 #4 0x000aac05 in __gnu_debug...

EnumChildWindows or FindWindowEx?

I have option to use any one of the API EnumChildWindows or FindWindowEx. Any suggestions which api is better performance oriented? Is FindWindowEx internally uses EnumChildWindows to get handle to particular window? ...

Boost: what exactly is not threadsafe in Boost.Signals ?

I read at multiple places that Boost.Signals is not threadsafe but I haven't found much more details about it. This simple quote doesn't say really that much. Most applications nowadays have threads - even if they try to be single threaded, some of their libraries may use threads (for example libsdl). I guess the implementation doesn't ...

Program stop to running when calls a process

Hi, I am trying to create a program that calls another process using CreateProcess. After some problems, I change my program to just open a known program: if( !CreateProcess( (LPWSTR)"C:\\Program Files\\Opera\\Opera.exe", // No module name (use command line) NULL, , // Command line NULL, // Process handle ...

Can't add static lib

I am trying to build a DLL and it needs to reference a library namely libeay32.dll from the openssl package. I cant seem to add it as a reference under the Property Pages->Common Properties->Add New Reference because it gives error "Could not add a reference to file 'C:\OpenSSL\libeay32.dll' because it is neither a .NET assembly or regis...

How to catch the null pointer exception ?

try { int* p = 0; *p = 1; } catch (...) { cout << "null pointer." << endl; } I tried to catch the exception like this but it doesn't work,any help? ...

how to pass "this" in c++

I'm confused with the keyword "this" in C++, i'm not sure that if i'm doing the right thing by passing "this". Here is the piece of code that I'm struggling with: ClassA::ClassA( ClassB &b) { b.doSth(this); // trying to call b's routine by passing a pointer to itself, should i use "this"? } ClassB::doSth(ClassA * a) { /...

Updating text in a C Win32 API STATIC control drawn with WS_EX_TRANSPARENT

I have window with some STATIC labels and BUTTONs on it. I make all the LABELS transparent background so I can make the background RED say. In the CALLBACK i process the WM_CTLCOLORSTATIC message, determine the ID of the control with GetDlgCtrlID() and then: SetBkMode((HDC)wParam, TRANSPARENT); // Make STATIC control Bkgd transparent re...

Simulated time in a game loop using c++

I am building a 3d game from scratch in C++ using OpenGL and SDL on linux as a hobby and to learn more about this area of programming. Wondering about the best way to simulate time while the game is running. Obviously I have a loop that looks something like: void main_loop() { while(!quit) { handle_events(); D...

How is memory allocated for a static multi-dimensional array?

All, This has been bugging me for a while now. In C\C++( i guess java and .NET as well) we do not have to specify the row index in a multi-dimensional array. So, for example i can declare an array of ints as such: int Array[][100]; I think static arrays in general are represented as contiguous memory on the stack. So, taking a column...

C++, manipulate 2d array

I have created a function to flip a square 2d array horizontally, so the first row is moved to the last, the second row is moved to the second from the last and so on. Here is the function: void flipMatrix(int size, int matrix[ROWS][COLS]) { int row, col; int temp[ROWS][COLS]; for (row=0; row < size; row++) { for (...

How do I factor code to ease testability?

I am learning about Unit Testing and want to know how to write testable code. But, I'm not sure how to write testable code without making it complex. I'll take famous Car and Engine problem to describe the problem. class Car { private: Engine m_engine; public: Car(); // Rest of the car } I came up with following solutions to...

What may cause losing object at the other end of a pointer in c++?

EDIT: I have found the error: I did not initialize an array with a size. question can be closed. I have a class V, and another class N. An object of N will have an array of pointers to objects of class V (say V **vList). So, N has a function like V **getList(); Now in some function of other classes or simply a driver function, if I ...

preorder an array based binary search tree

I am trying to preorder a BST I am not sure how to do it. ...

scope of local variables of a function in C

I have heard about the following scenario right when I started programming in C. "Trying to access from outside, a functions local variable will result in error (or garbage value). Since the stack gets cleared off when we return from the function" But my below code sample prints a value of 50. I am compiling the code with latest GCC c...

How to get IP address from sockaddr

I want to try and get the ip address of a client after calling accept. This is what I have so far, but I just end up getting some long number that is clearly not an ip address. What could be wrong? Thanks to anyone who replies. int tcp_sock = socket(AF_INET, SOCK_STREAM, 0); sockaddr_in client; client.sin_family = AF_INET; socklen_t...

Is there an string equivalent to LPTSTR?

Is there an string equivalent to LPTSTR? I know of string and wstring. Is there a tstring? ...

What does it mean by C++ runtime?

What are all the activities done by C++ runtime? ...

Statistical mathematics issues

Hello, I'm developing a Texas Hold 'em hand-range equity evaluator, which evaluates hand-distributions with Monte Carlo -simulation. I've faced two annoying problems which behaviors I cannot give any reason. Problem #1: In a nut shell, the evaluator works by first picking up hands from player's hand-distributions. Say, that we have th...

Hiding the Cursor

I have a windows program with directx/opengl renderers, and a custom mouse rendered as a quad. The program currently runs windowed. The problem is the standard windows mouse is overlaid ontop of my custom cursor. How do I hide it when its inside my window? ...