dereference

Pointer to an Element of a Vector

If I have a pointer that is pointing to an element in a vector, say element 2, and then that element gets swapped with element 4 of the same vector, Is the pointer now pointing to element 2, element 4, or neither? Example: vector a is equal to [1,2,3,4,5] create pointer that points to the element 2, which is equal to 3 in this case sw...

C++ noob question: pointers and overloaded []

I've been staring at this for a while and not getting very far. FruitBasketFactory, FruitBasket, and Fruit are three classes from an API I'm using. My goal is to make a fruit basket and then retrieve the fruit. According to the FruitBasketFactory.hpp: const FruitBasket* getFruitBasket() const; and then in the FruitBasket.hpp siz...

Why printf( "%s" , ptr ) is able to dereference a void*?

When we talk about dereference, is it necessary that * should be used in it? If we access the referent of the pointer in some other way, can it be considered as dereferencing a pointer or not, like: char *ptr = "abc" ; printf( "%c" , *ptr ); // Here pointer is dereferenced. printf( "%s" , ptr ); // What about this one? That is the f...

mysqli statement: fetch() an array of results

I use mysqli extension and bind the result to an object: class Item { public $id, $name; } $Item = new Item; $stmt->bind_result($Item->id, $Item->name); Every call to $stmt->fetch() will overwrite $Item's properties which became references. If I simply clone the object — these references remain and both instances change simult...

C++ beginner question: dereference vs multiply

hi, Just getting into C++. I'm getting constantly thrown off track when I see the symbol for multiply (*) being used to denote the dereferencing of a variable for example: unsigned char * pixels = vidgrabber.getPixels(); Does this throw other people off? What's the tip for getting my head around this? Thank you. p.s. I have an...

overloading dereference operator

hi, I am new to C++ and i have a question on overloading dereference operator. I am building a in memory object store which is to be used by the applications. The data store is mapped in to the applications memory space and applications can directly read/modify the object using dereference operator . I plan to provide an interface desc...

Is there a way to dereference a list in common lisp?

Is there a way to dereference a list in lisp? I am trying to compare 2 strings but one is in a list. ...

How do I dereference based on size?

I am trying to print the value pointed to by an address but the problem is I need to dereference this pointer based on the size that is passed to me. So something of this sort: void print(Address addr, Int size) { ... } I am a little confused on how to achieve this. Can someone point me in the right direction? EDIT: Ok so I'm thinkin...

C structure pointer dereferencing speed...

Hello. I have a question regarding the speed of pointer dereferencing. I have a structure like so: typedef struct _TD_RECT TD_RECT; struct _TD_RECT { double left; double top; double right; double bottom; }; My question is, which of these would be faster and why? CASE 1: TD_RECT *pRect; ... for(i = 0; i < m; i++) { if(p[...