Questions tagged [addressof]
95 questions
2
votes
3 answers
Difference between passing “pointer to pointer” and “address of pointer” to a function
I have a function that takes a char **; it uses it internally for maintaining context between successive calls.
What is the difference between defining char **x and passing x to it, and defining char *x and passing &x?
For context: I tried to…

Nour-eddin
- 63
- 7
2
votes
3 answers
Point to specific rows of 2-D arrays
I wrote the following code to point to first row of a 2-dimensional array. However, when I do
arrayPtr = & array[0];
I end up getting
error: cannot convert double (*)[1] to double* in assignment
arrayPtr = & array[0];
My program is:
#include…

Alexander Fell
- 185
- 1
- 11
2
votes
2 answers
passing address of variable to function
I am not great on pointers but I have to learn in the field. If my understanding serves me correct these should all be valid statements below.
int* a;
int b = 10;
a = &b;
(*a) = 20;
(*a) == b; //this should be true
if you have a function like…

user1610950
- 1,837
- 5
- 33
- 49
2
votes
1 answer
vb.net runtime buttons and "AddressOf " parenthese
in my system i am creating runtime buttons, i have create one sub to create all buttons which is fine for what i need however they all go to the same "addressOf" i want to create separate handlers, however it doesnt allow with my current method any…

notme61
- 45
- 1
- 9
2
votes
2 answers
Finding the difference between the addresses of elements in an array
I have an exam revision question on pointer arithmetic and one part where we are subtracting the address of two array variables is not making sense to me.
Well one array actually equals the other. I understand the individual outputs
for each array…
user3956566
2
votes
2 answers
Variable argument list: use va_list or address of formal parameter?
The code below contains 2 functions both of which calculate a sum of supplied list of integer values:
#include
#include
using namespace std;
int sum_1 ( int number_of_values, ... )
{
va_list arguments;
va_start (…

Vadim Drokov
- 109
- 6
2
votes
2 answers
AddressOf not working
I am having a issue with a c# to vb.net conversion, but AddHandler is not working for me. Can anyone help?
this.ucSurveyWebControl.OnResponseRecieved += new…

John D
- 79
- 1
- 3
1
vote
3 answers
Converting event-handling code from C# to VB.NET
I am trying to convert this code written in C# to VB:
// Initialize the Message Broker Events
(Application.Current as App).MessageBroker.MessageReceived += new MessageReceivedEventHandler(MessageBroker_MessageReceived);
(Application.Current as…

adam bond
- 19
- 2
1
vote
3 answers
AddressOf in Visual Basic .NET
I have buttons generated through code (dynamically). I have to associate an event (the same) to them. I use AddHandler button.click, AddressOf mysub.
The issue is that mysub gets a string (mysub(string)), but AddressOf doesn't accept a parameter…

Alph
- 33
- 2
- 2
- 5
1
vote
0 answers
Looking for method name by address in vb.net
This is not really a question because I found out how to do this.
Start with a delegate.
Public Delegate Sub PageFunction()
Then, define a function, for example:
Sub Action()
End Sub
Then you can get the function name from its address, like:
…

Rob
- 11
- 2
1
vote
2 answers
Address of an address in C. Valid or not?
I thought I understood c and pointers but was just debugging someone elses code that I thought should not work but did.
As a (crude) example....
void clear_buffer(char* buff, int len)
{
while(len)
{
*buff++ = ' ';
len--;
…

Toby
- 131
- 2
- 8
1
vote
1 answer
Is it possible to stop std::addressof on my objects?
For some educational reason I managed to stop others from taking the address of my class objects through overloading the reference operator & as a deleted member function or as a private method. But C++11 presents a new templated-function…

Alex24
- 600
- 2
- 13
1
vote
2 answers
Use case of overloading address-of operator
I think it's dangerous to overload the address-of operator &, because it's easy to overlook the use of std::addressof() in implementing templates that actually need it. Still, I'm wondering what would be a proper use case of overloading this…

Lingxi
- 14,579
- 2
- 37
- 93
1
vote
0 answers
Accessing field of NULL pointer to a struct works if address-of is used
I've just encountered a VERY weird thing:
I have a struct, say:
typedef struct {
int x;
} STRUCT;
[I know I can just say struct STRUCT without the typedef :)]
and a pointer STRUCT *p = NULL;
Suppose this pointer is (still) null at the time I…

PhantomR
- 605
- 4
- 16
1
vote
3 answers
Get Actual Parameter Types From Action Delegate
Context
Here's a very specific problem for ya. To sum things up, I have a class which queues delegates to run later. I know each method will only have one argument, so I stores these in a list of Action(Object). I can't use generics because…

Keith Stein
- 6,235
- 4
- 17
- 36