FAQ Database Discussion Community


Why can static member functions only be called at global scope if they have a return value?

c++,static,member-function
I found a peculiar thing: static member functions of a class/struct cannot be called a global scope, unless they have a return value. This program does not compile: struct test { static void dostuff() { std::cout << "dostuff was called." << std::endl; } }; test::dostuff(); int main() { return 0;...

How can I pass a member function pointer into a function that takes a regular function pointer?

c++,pointers,function-pointers,member-function
I have a player class which looks like this (stripped down to what is needed for this problem): class Player { public: Player(); ~Player(); void kill(); void death(); void reset(); }; The kill(), death(), and reset() functions look like this: void Player::kill() { void (*dPtr)() = &death; Game::idle(dPtr, 48); }...

ZF 2 - Fatal Error: Call to a member function getPosts() on null

php,zend-framework2,fatal-error,member-function
I am creating a website using Zend Framework 2, and I'm using as an example the exercise from the official course of Zend Technology, Zend Framework 2: Fundamentals. I have a table called posts and I want to show the table content in my home page, ordered by id. These...

Binding multiple pthreads, each to the same member function of a different object from the same class

pthreads,member-function
I have bound multiple pthreads to independent member function of independent objects from the same class. I had to use of a static member function as a helper since it is not possible to bind a member function directly to a pthread in C++; however, my application behaves strangely and...