Essay Database
C++ Review Topics
Date Submitted: 01/12/2002 17:28:46
C++ fully supports object-oriented programming which includes the following:
Encapsulation is the property of being a self-contained unit. With encapsulation we can accomplish data hiding. Data hiding is the highly valued characteristic that an object can be used without the user knowing or caring how it works internally. C++ supports the properties of encapsulation through the creation of user-defined types, called classes.
Inheritance allows for the extension of an existing type. The new subclass derives
Is this Essay helpful? Join now to read this particular paper
and access over 800,000 just like this GET BETTER GRADES
and access over 800,000 just like this GET BETTER GRADES
data
private:
unsigned int itsAge;
unsigned int itsWeight;
};
The above class has five public methods. There are accessor functions GetAge and SetAge for itsWeight. These accessor functions set the member variables and return their values.
The public member function Meow() is not an accessor function--it doesn't get or set a member variable.
To set Frisky's age, you would pass the value to the SetAge method as in:
Cat Frisky;
Frisky.SetAge(5); //uses public accessor function
Need a custom written paper? Let our professional writers save your time.