1 2 3 4 5 6 7 8 9

Anatomy of a class


What can exist inside a class?


Data members--these are like the elements inside a C-style
struct.


Member functions--these are the operators in an ADT, and
form an important contribution of C++.


A member function is defined in the context of a particular
class. In other words a class contains data and capabilities.


Member functions are intended to be the primary means for
the manipulation of objects of a given class.


An example
class Complex {
double real;
double imaginary;
}
This a simple class declaration and it allows us to create an
instance with:


Complex variable;


Note:we could have done this as easily in C with:
typedef struct {
double real;
double imaginary;
} Complex;

8 March, 1998

Page {PAGE }

TAM/DS