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
43
votes
6 answers

C programming: Dereferencing pointer to incomplete type error

I have a struct defined as: struct { char name[32]; int size; int start; int popularity; } stasher_file; and an array of pointers to those structs: struct stasher_file *files[TOTAL_STORAGE_SIZE]; In my code, I'm making a pointer to the…
confusedKid
  • 3,231
  • 6
  • 30
  • 49
40
votes
7 answers

What's the difference between * and & in C?

I'm learning C and I'm still not sure if I understood the difference between & and * yet. Allow me to try to explain it: int a; // Declares a variable int *b; // Declares a pointer int &c; // Not possible a = 10; b = &a; // b gets the address of…
Cristian Ceron
  • 695
  • 1
  • 8
  • 12
40
votes
4 answers

Is it possible to dereference variable id's?

Can you dereference a variable id retrieved from the id function in Python? For example: dereference(id(a)) == a I want to know from an academic standpoint; I understand that there are more practical methods.
Hophat Abc
  • 5,203
  • 3
  • 18
  • 18
39
votes
3 answers

what is return type of assignment operator?

I am just starting C++. I am a bit confused about the return type of assignment and dereference operator. I am following the book C++ Primer. At various occasions, the author says that the return type of assignment operator is reference to the type…
oczkoisse
  • 1,561
  • 3
  • 17
  • 31
37
votes
4 answers

What's the use of multiple asterisks in the function call?

I can't think of any practical use of multiple asterisks in the function call: void foo(int a, char b) { } int main(void) { (**************foo)(45, 'c'); //or with pointer to function: void (*ptr)(int, char) = foo; (******ptr)(32,…
Quentin
  • 1,090
  • 13
  • 24
30
votes
3 answers

Why is dereferencing a pointer called dereferencing?

Why is dereferencing called dereferencing? I'm just learning pointers properly, and I'd like to know why dereferencing is called that. It confused me as it sounds like you are removing a reference, rather than going via the pointer to the…
Chris Barry
  • 4,564
  • 7
  • 54
  • 89
29
votes
5 answers

C# Namespace Alias qualifier (::) vs Dereferencing Operator (.)

Quick and simple question. I kind of understand what the Namespace Alias qualifier does, it's for accessing members in a namespace, however so does the dereferencing operator. I am really baffled as to the difference in this situation, why you would…
Francisco Aguilera
  • 3,099
  • 6
  • 31
  • 57
28
votes
2 answers

When the dereference operator (*) is overloaded, is the usage of *this affected?

For example, class Person{ string name; public: T& operator*(){ return name; } bool operator==(const Person &rhs){ return this->name == rhs.name; } bool operator!=(const…
user7547935
27
votes
1 answer

In Delphi/Free Pascal: is ^ an operator or does it simply denote a pointer type?

In Delphi/Free Pascal: is ^ an operator or does it simply denote a pointer type? Sample code program Project1; {$APPTYPE CONSOLE} var P: ^Integer; begin New(P); P^ := 20; writeln(P^); // How do I read this statement aloud? P is a…
Adam Scott Roan
  • 273
  • 1
  • 3
  • 5
26
votes
3 answers

Is dereferencing null pointer valid in sizeof operation

I've come across a snippet of code that to me should crash with a segmentation fault, and yet it works without a hitch. The code in question plus relevant data structure is as follows (with associated comment found right above): typedef struct { …
Veeg
  • 315
  • 4
  • 7
23
votes
3 answers

Difference between dereferencing pointer and accessing array elements

I remember an example where the difference between pointers and arrays was demonstrated. An array decays to a pointer to the first element in an array when passed as a function parameter, but they are not equivalent, as demonstrated next: //file…
bolov
  • 72,283
  • 15
  • 145
  • 224
22
votes
3 answers

Pointer Arithmetic: ++*ptr or *ptr++?

I am learning C language and quite confused the differences between ++*ptr and *ptr++. For example: int x = 19; int *ptr = &x; I know ++*ptr and *ptr++ produce different results but I am not sure why is that?
ipkiss
  • 13,311
  • 33
  • 88
  • 123
22
votes
4 answers

What does this pointer of type structure definition mean (in C)?

In K&R Chapter 6, a declaration is mentioned as follows: struct{ int len; char *str; } *p; I couldn't understand which structure is this pointer p pointing to and if such a pointer definition is even valid because in all other examples…
Eulerian
  • 382
  • 2
  • 8
20
votes
1 answer

What is the relation between auto-dereferencing and deref coercion?

After some discussion, I'm now a little bit confused about the relation between auto-dereferencing and deref coercion. It seems that the term "auto-dereferencing" applies only when the target to dereference is a method receiver, whereas it seems…
attdona
  • 17,196
  • 7
  • 49
  • 60
20
votes
3 answers

Can I get a Python object from its memory address?

I'm learning how to use Qt with PyQt, and I have a QTabelView with a StandardItemModel I've populated the model successfully and hooked up the itemChanged signal to a slot. I'd l'd like to mess around with whatever object is returned in IPython, so…
Erotemic
  • 4,806
  • 4
  • 39
  • 80
1
2
3
78 79