1,037 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
2
answers
210
views
Getting address of non-static member function for locating its shared library
I have a situation similar to described in a blog post: a visible inline member function is called from several shared libraries which are built potentially with different compilers or compiler ...
1
vote
1
answer
51
views
How to pass a pointer to member function to a template function
Here is my simplified code: S.h
class SBase {
...
public:
virtual std::vector<int32_t> getNumbersSet1();
virtual std::vector<int32_t> getNumbersSet2();
}
class SDerived : public ...
15
votes
2
answers
811
views
MSVC calls wrong virtual method when storing a pointer to virtual method in a static inline variable
I'm encountering unexpected behavior on MSVC when storing a pointer to a virtual method in a static inline variable. The issue does not occur on GCC or Clang.
Specifically, when I store a pointer to a ...
3
votes
1
answer
81
views
Can't call stored member function on stored object
I'm trying to create sort of an event system, I don't care if it is suboptimal, I'm doing it for fun. I do not want alternate solutions, I want to understand why this isn't working and how could I fix ...
-1
votes
2
answers
232
views
Why ISO C++ forbid taking the address of a bound member function to form a pointer to member function?
Here is the error in GCC (which i have already fixed):
ISO C++ forbid taking the address of a bound member function to form a pointer to member function
This is the error line of my code:
threads[i] ...
8
votes
2
answers
198
views
Get pointer to derived class member made public with using declaration
Consider a base class with a couple of public fields and a derived class which inherits the base privately and makes one of the inherited fields public via the using declaration. I need to access this ...
-1
votes
1
answer
116
views
C++ Reference is not updating when referenced-variable is [duplicate]
I recreated small example of a problem I'm seeing.
I have two classes. Class Owner has a member variable, a. Class Client has a member variable which references the member variable a from the Owner ...
0
votes
0
answers
50
views
deduct holder's class of c++ 'pointer to member' of derived class
I think this question is related to C++ pointer to member of derived class, but slightly different.
I have a class accepts a pointer-to-member as template parameter, and will deduct the holder's type ...
0
votes
2
answers
106
views
How to use a pointer to a member function as a field of a struct data member to call a member function? [duplicate]
I am trying to port C code to a C++ program and thus encapsulate the logic from the C program inside a C++ class. The step I am stuck at is using a function pointer, which is a field inside a struct ...
0
votes
1
answer
89
views
Can a pointer to member function be used directly with reinterpret_cast?
A pointer to member function isn't a regular pointer.
but a pointer to a pointer to member function does.
struct X {
void func() {}
};
int main() {
auto p1 = &X::func;
auto p2 = &...
1
vote
1
answer
58
views
How to send a pointer of a method of an object into a function?
I'm trying to create a notebook program
cpp file:
#include <string>
#include "Menu.h"
class Notebook
{
std::vector<std::string> m_notes;
public:
void addNote()
{
...
1
vote
1
answer
127
views
Why do we need to refer to the object to access a pointer to a member function?
class Harl {
private:
void debug( void );
void info( void );
void warning( void );
void error( void );
public:
void complain( std::string level );
};
...
1
vote
0
answers
56
views
Assign member function to base class function pointer [duplicate]
I have to implement a low-level interface for the library which exposes structure with a function pointers like this:
struct Interface {
int (*IterfaceFn) (int value);
};
Library then expects a ...
0
votes
1
answer
75
views
How to choose const method overload when casting of method pointer is made [duplicate]
I have a class with overloaded method:
#include <iostream>
#include <utility>
struct Overloads {
void foo() {
std::cout << "foo" << std::endl;
}
...
2
votes
1
answer
86
views
Member pointer template parameter pointing into the object being templated
I would like to have a base class that I derive from that offers serialization mechanism:
template <typename Type, typename Class, Type Class::* Member>
class Serializable
{
public:
void ...