pointers

Function Pointers in Java

This may be something common and trivial, but I seem to be having trouble finding a concrete answer. In C# there is a concept of delegates, which relates strongly to the idea of function pointers from C++. Is there a similar functionality in Java? Given that pointers are somewhat absent, what is the best way about this? And to be clear, ...

Greyscale darkening problem with Bitmap image in C#

I'm loading a 8bppIndexed greyscale image into memory and reading the pixel values. The problem is that the values I am getting from the pixels do not seem to match the actual image, they are always darker. My image is a simple grey gradient like this: The bottom right pixel is returning 191 and the top left 0. The top left is actu...

Problem with realloc of **struct

Hi Mates, I have a problem with realloc function in C. I'm passing you a code bellow: typedef struct _Pool Pool; typedef struct _Item Item; struct _Pool { Item ** items; unsigned int itemsCount; unsigned int poolSize; unsigned int poolStep; }; struct _Item { char * file; unsigned int lenOfFilePath; unsign...

Calling a Delphi DLL from C# containing Pointer in struct not working

I have a delphi dll that is defined like this type tSSL_connect = packed record pssl : Pointer; pctx : Pointer; sock : Integer; end; function SSLCLT_Connect(pIPAddr: PChar; iPort: Integer; var pConn: tSSL_connect; iTimeout: Integer; bEnableNonBlockingMod...

Why does C++ use pointers?

Why does C++ need and use pointers? I know they add power to the language but they make it a lot harder to understand for beginners. Languages like F#, Java, Ruby, Python, Lua, etc. get by just fine without them, and they're quite powerful. ...

c++ * vs & in function declaration

Possible Duplicate: Difference between pointer variable and reference variable in C++ When should I declare my variables as pointers vs objects passed-by-reference? They compile to the same thing in assembly (at least run-time asymptotically) so when should I use which? void foo(obj* param) void foo(obj& param) ...

destructor problem

this is my addCard function which takes a playingCard as a parameter then hands over the address of its self to an allocated array of pointers to playingCard objects. void cardHand::addCard(playingCard card) { theHand[nElems++] = &card; } // addCard() now when i run my program it runs fine but then crashes when the destructor is c...

For Objective-C ... Pointer to method

I want to setup a Method dispatch table and I am wondering if it is possible to create pointer to a method in Objective-C (like pointer to function in C). I tried to use some obj-c runtime functions to dynamically switch methods but the problem is it will affect all instances. As I am very new to obj-c, an illustrated example would be ...

dereferencing pointer to integer array

I have a pointer to integer array of 10. What should dereferencing this pointer give me? Eg: #include<stdio.h> main() { int var[10] = {1,2,3,4,5,6,7,8,9,10}; int (*ptr) [10] = &var; printf("value = %u %u\n",*ptr,ptr); //both print 2359104. Shouldn't *ptr print 1? } ...

STL List to hold structure pointers

I have a structure called vertex and I created some pointers to them. What I want to do is add those pointers to a list. My code below, when it tries to insert the pointer into the list, creates a segmentation fault. Can someone please explain what is going on? #include <iostream> #include <list> #define NUM_VERTICES 8 using namesp...

Where is my 'this'? Using objects method as a callback function.

Hello, I have a generic question about javascript specification or implementation of functions pointer (delegates?) which are points to object methods. Please, read the following code snippet. Here we have an object with a method using 'this' to access an object field. When we call this method as usual (o.method();), returns value of ...

Pointer to pointer confusion

Edit: The reason queue is 2d is because I need a pointer of Command so that cmd can equal NULL. NULL == (void *). This is where I get confused though, and why I've come here. :) To help try and figure out another problem I have in Python, I'm implementing a small test program in C. While I know a little, apparently I'm confused. I'm try...

String length between pointers

Hi, I ran into a little problem and need some help: If I have an allocated buffer of chars and I have a start and end points that are somewhere inside this buffer and I want the length between these two point, how can I find it? i.e char * buf; //malloc of 100 chars char * start; // some point in buff char * end; // some point after s...

Array of member function pointers : Getting 0xcccccccc when control reached pointer to member function

Hi, I got error Access Violation when the following code is execute : void NoAction() { (*m_psStateMachine[0][0])(); } class CXcp { public: CXcp(){} CXcp(WORD wXcpProtocol); ~CXcp(); private: void (*m_psStateMachine[10][16])(); public: // Action Methods from State M/c Table in the RFC// void IrcScr_6(){} void IrcS...

Is there a function pointer or array of functions in PowerShell?

I would like to do something like this. Index into an array of functions and apply the appropriate function for the desired loop index. for ($i = 0; $i -lt 9; $i++) { $Fields[$i] = $Fields[$i] | $($FunctionTable[$i]) } #F1..F9 are defined functions or rather filter functions $FunctionTable = {F1}, {F2}, ...

Placement of the asterisk in Objective-C

I have just begun learning Objective-C, coming from a VB .Net and C# .Net background. I understand pointer usage, but in Objective-C examples I see the asterisk placed in several different places, and search as I might, I have not been able to find an answer as to why this is. Every search I try turns up all kinds of explanations about...

How to gain Access to member variables of a class using void pointer but Not Object

Hi, I am trying to access member variables of a class without using object. please let me know how to go about. class TestMem { int a; int b; public: TestMem(){} void TestMem1() { a = 10; b = 20; } }; void (TestMem::*pMem)(); int main(int argc, char* argv[]) { TestMem o1; pMem = &(TestMem::T...

Scope, arrays, and the heap

Hello, So, I have this array. It needs to be accessed outside the scope of this function. I have been slapping a pointer to it into a pair which gets put into a deque. But once I'm outside the scope, the local stack is gone, the array is invalid, and I've just got a useless pointer, right? So I've trying to put this array onto the scop...

C pointers Question

For : int *a; a is an address where an integer can be stored. &a is an address where a is stored. Then, where is &a stored? And, where is &(&a) stored? And, where is &(&(&a)) stored? Where does this storing of addresses stop? ...

New to C++. Question about constant pointers.

I am trying to learn C++ via some web tutorials. I don't have a compiler available to me, otherwise I would try this out. I'm not sure what is meant by a const pointer. Does that just mean it always points to the same memory address? Why would you ever want to do that? Would the following code be legal? ... int * const aPointer = ne...