pointers

Using Python's ctypes to pass/read a parameter declared as "struct_name *** param_name"?

I am trying to use Python's ctypes library to access some methods in the scanning library SANE. This is my first experience with ctypes and the first time I have had to deal with C datatypes in over a year so there is a fair learning curve here, but I think even without that this particular declaration would be troublesome: extern SANE...

references in visual basic .net

Hi, Somewhat unclear to me are references (pointers?) to classes in Visual Basic .Net. The question I am about to ask can be answered by a little bit of testing, but I was wondering if anybody could post a decent explanation (or links, too). If you create a class: Public Class ReferenceClass private myBooleanValue as Boolean = F...

Beginner C Programmer needs help with pointers ( I think )

I'm a beginner programmer and I'm learning my first language, C. I'm learning mostly from Deitel and Deitel's C How to Program book, but also using example tasks and things from the university, however I am stuck on one. I have a very very basic understanding of pointers - adding & in front of a variable makes it print an address and ...

Pointer Arithmetic

Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure the audience is a bunch of Java programmers learning C and C++. ...

C++ 2DArray Objects; Pointers and Array Problems

This problem is from a solved problem in my old question, which is from: http://stackoverflow.com/questions/394763/c-inserting-2d-array-object-into-another-2d-array-object But also created a new problem for me. Please read the question and the solution in the link to understand my problem. The solution in the previous question was to ma...

calling code stored in the heap from vc++

Imagine I am doing something like this: void *p = malloc (1000); *((char*)p) = some_opcode; *((char*)p+1) = another_opcode; // for the sake of the example: the opcodes are ok .... etc... How can I define a function pointer to call p as if it was a function? (i'm using VC++ 2008 express). Thanks ...

When to use pointers and when not to?

I'm used to doing Java programming, where you never really have to think about pointers when programming. However, at the moment I'm writing a program in C++. When making classes that have members of other classes, when should I use pointers and when should I not? For example, when would I want to do this: class Foo { Bar b; } As ...

In C, why is the asterisk before the variable name, rather than after the type?

In my experience, everyone names variables like this: int *myVariable; Rather than like this: int* myVariable; Both are valid. It seems to me that the asterisk is a part of the type, not a part of the variable name. Can anyone explain this logic? ...

how to set pointer to a memory to NULL using memset?

Hi, I have a structure typedef struct my_s { int x; ... } my_T; my_t * p_my_t; I want to set the address of p_my_t to NULL, tried: memset (&p_my_t, 0, sizeof(my_t*)) This does not look right, what is the correct way of doing this? appreciate it... Amendment to question - asking a radically more complex question: Thank...

Pointer class assistance

I'm writing a sparse matrix class in C++ in which every row and column are arrays of linked lists from a class I created (aptly named: LinkedList). I want to write a class that is a "smart" pointer to one cell in this matrix. In that class, let say LIPointer, I will implement a ++ operator function for moving in the linked lists of the...

Help--Function Pointers in Python

My idea of program: I have a dictionary: options = { 'string' : select_fun(function pointer), 'float' : select_fun(function pointer), 'double' : select_fun(function pointer) } whatever type comes single function select_fun(function pointer) gets called. Inside select_fun(function pointer),I will have diff functions for float, double ...

Passing function Pointers in C++

i want to do this simple piece of code work. #include <iostream> #include <windows.h> void printSome (int i) { std::cout << i << std::endl; } void spawnThread (void (*threadName)(int i)) { CreateThread ( 0, // default security attributes 0, // use default stack s...

Passing Pointer To An Array Of Arrays Through Function

Hi There is a pointer-to-an-Array of Arrays i.e. NameList in the code. I want the contents of each of the Arrays in the Pointer(NameList) to get printed one by one. The below code is not able do the task. Pls. help. int Data1[] = {10,10}; int Data2[] = {20,20}; int Data3[] = {30,30}; int *NameList[] = {Data1, Data2, Data3}; main()...

Pointer to void in C++?

Hello, I'm reading some code in the Ogre3D implementation, and I can't understand what does a void*-typed variable could mean. What does a pointer to void means in C++? ...

On writing win32 api wrapper with C++, how to pass this pointer to static function

I want to convert function object to function. I wrote this code, but it doesn't work. #include <iostream> typedef int (*int_to_int)(int); struct adder { int n_; adder (int n) : n_(n) {} int operator() (int x) { return x + n_; } operator int_to_int () { return this->*&adder::operator(); } }; int main(void...

Pointers, smart pointers or shared pointers?

I'm programming C++ with normal pointers, but I have heard about libraries like Boost that implement smart pointers and I have seen that in Ogre3D rendering engine there is a deep use of shared pointers. What's exactly the difference between the three, and should I stick on using just a type of them? Thanks. ...

Array over written with last value assigned?

I have a pointer to pointer array. I am assigning each row in the while loop below and the printf inside the while loop shows each is assigned my id number 1-20. After, out side of the while loop I iterate through the array and every element is written with id 20? Any help is greatly appreciated. (FYI- I am using the Template2doc library...

Is this' type variableofType()' function or object?

#include<iostream> class name { public: int a; name():a(0){}; }; void add(name * pname) { pname = NULL; } int main() { name varName(); name * pName = new name(); add(pName); add(&varName);//error C2664: 'add' : cannot convert parameter 1 from 'name __cdecl *)(void)' to 'name *' } ...

How to cast member variable pointer to generic type in C++

I have code similar to this in my application: class A { public: int b; } class C { public: int d; } void DoThings (void *arg1, MYSTERYTYPE arg2); A obj_a; C obj_c; DoThings(&obj_a, &A::b); DoThings(&obj_c, &C::d); The question is - What should MYSTERYTYPE be? neither void* nor int work, despite the value &A::b being printed j...

In C++, can I define a pointer-to-member of a private class outside its scope?

Consider: class C { private: class T {int a, b;}; }; C::T *p; As expected, this produces a compilation error saying that C::T is private in the context of Line 6. Now change this to pointer-to-member: class C { private: class T {int a, b;}; }; int C::T::*p; This time around, gcc version 3.2.3 still makes the same complaint...