Questions tagged [dereference]

Anything related to pointer dereference, i.e. the process of determining the object which the pointer is referring to. Languages having pointer variables usually have a special operator to perform dereferencing of pointers (e.g. in C and C++, if `p` is a valid pointer, `*p` is the object pointed to by `p`).

Anything related to pointer dereference, i.e. the process of determining the object which the pointer is referring to. Languages having pointer variables usually have a special operator to perform dereferencing of pointers (e.g. in C and C++, if p is a valid pointer, *p is the object pointed to by p).

1184 questions
4
votes
2 answers

How to cascade -> operator?

I have the following: typedef struct Node_struct { int number; Node *nextNode; Node *prevNode; } Node; and later Node *nodeInSet = lookup(set, number); nodeInSet->nextNode = (Node *)…
Utku
  • 2,025
  • 22
  • 42
4
votes
2 answers

Cost of union access vs using fundamental types

I have a large block of data where some operations would be fastest if the block were viewed as an array of 64 bit unsigned integers and others would be fastest if viewed as an array of 32 bit unsigned integers. By 'fastest', I mean fastest on…
jack
  • 282
  • 2
  • 9
4
votes
5 answers

Difference between these two statements? - C++

I'm a programming student trying to better understand pointers, one of the things I learned is that you can set a pointer to NULL. My question is, what's the difference between these two statements? When would each of them return true/false? if…
Alex
  • 64,178
  • 48
  • 151
  • 180
4
votes
2 answers

Most vexing parse and pointer indirection/dereferencing

Minimal code: struct A { A(int = 0) {} }; int i = 0, *p = &i; int* foo () { return p; } int main () { A(); // calls `A::A(int=0)` A(i); // calls `A::A(int=0)` A(*p); // <--- (1) same as local `A *p;` { A((*p)); // <--- (2) same…
iammilind
  • 68,093
  • 33
  • 169
  • 336
4
votes
2 answers

How to dereference a string that might be null in LINQ

Let's say I need to compare an object to other objects stored in a table called Indexes in my DB. I need to compare by the object's X property, which is a string, but it might be null. I also have to trim my comparedObject's X property before…
Omri Aharon
  • 16,959
  • 5
  • 40
  • 58
4
votes
3 answers

Dereference pointer with ARC in C function in iOS

I'm using The Amazing Audio Engine to handle playback in syncing in an iOS app. The framework requires you to use C functions as the call back (playbackTimingReceiver) which is called on the audio thread. You then need to message the main thread…
Brendt
  • 397
  • 1
  • 9
4
votes
3 answers

Post-incrementing an iterator after de-referencing - *iter++. How is it evaluated?

I couldn't find a better title for this issue, please update it if needed as per the below question. Consider an iterator - iter, pointing to elements in a std::vector. I'm inserting the value of *iter at the current iterator position…
Rohit Jain
  • 209,639
  • 45
  • 409
  • 525
4
votes
2 answers

Looping through hash of arrays in Perl

I have a hash of arrays, as follows: my %hash = ( 234 => ["Larry", "Curly", "Moe"], 235 => ["bb", "ab", "aa", "ab", "bb"], 236 => ["aa", "ab", "bb", "aa", "bb"], ) For each key in my hash, I would like to loop through each element of the array,…
cooldood3490
  • 2,418
  • 7
  • 51
  • 66
4
votes
2 answers

Pointing dereference inside a struct error

i have a function to create a circular list, i am having issues compiling, not sure if it is syntax, appreciate if someone can help. void CreateCircularList(struct node** listRef, struct node** tailRef) { Push(&*listRef, "String…
jelipito
  • 171
  • 2
  • 2
  • 12
4
votes
2 answers

How dereference works in Objective-C

I was trying to understand dereferencing in Objective-C and wrote below two methods. -(void)alterStringModelOne:(NSMutableString**)string{ NSMutableString *str = [NSMutableString stringWithString:@"New string by string = &str"]; string =…
Saran
  • 6,274
  • 3
  • 39
  • 48
4
votes
4 answers

Match Array to a Value within an Array of References - Perl

I have the following array of references to arrays: my @holidays =…
voteblake
  • 329
  • 1
  • 3
  • 11
4
votes
2 answers

Pointers on Objective-c

From what I understand (and please correct me if I'm wrong): int x, count = 10; int *hello; hello = &count; x = *hello; Here the variables x and count are declared to be of type integer. Additionally, the variable count is assigned the value of…
luca
  • 36,606
  • 27
  • 86
  • 125
4
votes
2 answers

'*{}' seems to be a valid Perl5 dereferencing operator (perldoc: overload). What does it dereferences to?

While reading about the pragma overload of Perl5, I noticed the operator *{}. I'd like to know what kind of sigil * is, if any, or what's the meaning of * in a ref context.
mgodinho
  • 155
  • 2
  • 6
3
votes
4 answers

Perl - Assign variables to values of references

There is a similar question How can I assign the result of a subroutine call to array references in Perl? but I'm curious about perl's possibilities Is there a hack in perl to directly dereference element-wise an array of references? in a code…
Hachi
  • 3,237
  • 1
  • 21
  • 29