April 2017
Beginner to intermediate
394 pages
9h 16m
English
Now that we know how to use pointers to member functions, we can create commands that can take an object and a specific member function to call. Just like before, we will use a simple example. The example class isn't designed to do anything interesting, it is just used to demonstrate the concepts:
class SomeObject { public: SomeObject(int x):m_x(x){} void Display(void) { std::cout << "x is " << m_x << std::endl; } void Change(void) { m_x += m_x; } private: int m_x; };
Here is a simple class called SomeObject. It has a constructor that takes an int parameter and uses it to set the private member variable m_x. It also has two functions: one that will print the value to the screen and one that changes the ...
Read now
Unlock full access