[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.

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?

last edited (August 12, 2005) by Garganus, Number of views: 2311, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.