Thread View: gnu.gcc.help
1 messages
1 total messages
Started by Sam S. Wong
Fri, 16 Oct 1992 20:00
C++ How do I print function addresses?
Author: Sam S. Wong
Date: Fri, 16 Oct 1992 20:00
Date: Fri, 16 Oct 1992 20:00
56 lines
1646 bytes
1646 bytes
Hi. I need some help.
I have class definition called ADC32. This class has as a member, a public
function called display().
I have two data objects. One is a variable of class ADC32 called slot1_adc,
the other is an array of 10 objects of class ADC32 called adc32.
The relevant code looks something like this:
//////////////////////
class ADC32 {
private:
int id;
public:
int display(void);
}
ADC32::display(void)
{
cout << id;
}
ADC32 slot1_adc32, adc32[10];
main {
cout << (int)&slot1_adc32.display;
cout << (int)&adc32[1].display;
}
///////////////
My question is, is the last 2 lines correct for displaying the addresses of
those two functions?
If not, what would those 2 statements produce?
What I have found is that: (int)&slot1_adc32.display gives me the address of
ADC32::display() instead of a pointer to the address of ADC32::display().
I am trying to confirm that no space is allocated for an object's member
functions. In other words, while there is space allocated for slot1_adc32.id
(4 bytes for an int), no space (for a function pointer) is allocated for
slot1_adc32.display().
what would be the result of:
"cout << (int)slot1_adc32.display;
cout << (int)adc32[1].display;" ?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads