[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
member function
Member function
A function that is part of a class. Or, in other words, a function established inside a class which then exists only within that class's scope.
These functions, being in MyClass' scope in this case, means that they only read and write in instances of MyClass. For some purposes it's as if that these functions are within the namespace, MyClass. This distinction is even more clear when you separate the class definition and declaration:
Recognize the scope operator?
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
member function
Member function
A function that is part of a class. Or, in other words, a function established inside a class which then exists only within that class's scope.
class MyClass
{
public:
MyClass(const double& value) { mValue = value; }
double setValue(const double& value) { mValue = value; }
double getValue() const { return mValue; }
private:
double mValue;
};
In this example, 'setValue' and 'getValue' are member functions. 'mValue' is a member variable. These functions, being in MyClass' scope in this case, means that they only read and write in instances of MyClass. For some purposes it's as if that these functions are within the namespace, MyClass. This distinction is even more clear when you separate the class definition and declaration:
double MyClass::setValue(const double& value) { mValue = value; }
double MyClass::getValue() const { return mValue; }
Recognize the scope operator?
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
