Page 72 - PowerPoint Presentation
P. 72
CAVITE STATE UNIVERSITY
T3 CAMPUS
Department of Information Technology DCIT 25 – Data Structures and Algorithms
Accessing Members of a Class
Attributes, methods and functions are referred to as members of a class. You access
members of an instance of a class using the name of the instance, the dot operator and the
name of the member, much the same ways as you access an element of a structure.
Here is how to access the grade attribute of the myStudent instance of the
StudentRecord class and call the displayGrade() method:
myStudent.grade = ‘A’;
myStudent.displayGrade();
QUIZ 3. Question and Answer (3 pts each except for no. 6 (5pts))
1. What is a user-defined data type?
2. How do you determine the size of a Structure?
3. Why would you use a Structure?
4. How do you determine the size of a Class?
5. Why would you use a Class?
6. Differentiate Structure to a Class
Page | 19