Questions tagged [member-pointers]
82 questions
0
votes
1 answer
Assign the designated function to the function member pointer?
Given
void* hello () {
cout << "Test.\n";
}
and
struct _table_struct {
void *(*hello) ();
};
How do we assign the function (hello) to the function member pointer?
I tried this (in main):
_table_struct g_table;
_table_struct…

Ursa Major
- 851
- 7
- 25
- 47
0
votes
2 answers
How do I access a pointer member inside a structure in C?
struct sample
{
int a;
char b;
float c;
int *al;
union un
{
int a;
char c;
float f;
}*ptr;
}test;
How do I access the structure member 'al' and the union members a,c,f?

Arun
- 45
- 1
- 5
0
votes
1 answer
C++, how do I find the address of a member function?
I have a specific problem I'm trying to solve, I need to find the location (in memory) of a class's method. I think I've hit a syntax constraint because a pointer to a method is handled as a member pointer Example:
class Foo {
public:
int…

Nathan Goings
- 1,145
- 1
- 15
- 33
-1
votes
1 answer
passing pointer to multiply classes to a member function
I have the next classes:
"Integrator.h"
#include
#include
using namespace std;
class Integrator {
public:
using coord_type = array;
protected:
void base_integrate_callback(const coord_type, double t_k) {
…

Artem Zefirov
- 423
- 5
- 14
-3
votes
1 answer
Method pointer and constness
Consider the following hypothetical example:
template
R call(T& t, R (T::*method)(Ps...), Ps... ps){
return (t.*method)(ps...);
}
struct A{
int f(int i) const {return i;}
};
A a;
Then call(a, &A::f,…

Bubaya
- 615
- 3
- 13
-3
votes
1 answer
Dereferencing a member Pointer
I am implementing a doubly linked list and I am getting a segfault when I try to access a member veritable of an object pointed at by a member pointer. My linked list is composed of Nodes, which have a value and a next and previous pointer
String…

iambicSam
- 347
- 1
- 2
- 11
-5
votes
1 answer
Confused about the point of class member in C++
Three classes as below:
class Base
{
public:
int var1;
};
class Base2
{
public:
int var2;
};
class Derive:public Base,public Base2
{
public:
int var3;
};
int main()
{
printf("%d %d %d %d %d", &Base::var1, &Base2::var2,…

tenos
- 909
- 1
- 9
- 16