-
Notifications
You must be signed in to change notification settings - Fork 0
Class
Delton Hughes edited this page Apr 29, 2023
·
1 revision
Definition: A class is the foundation of OOP, it allows us to create a particular data structure, providing member variables and attributs, and implementing member functions or methods. Coding example:
class student { private: string name; string major; int numClasses; double GPA; public: //constructor Student(){ name = "Nobody"; major = "CMPS"; numClasses = 0; GPA = 0.0; } //accessor method string getName(){ //because this only has access to private return name; } //Mutator function to set the numClasses void setNumClasses(int classes){ //Only stores if valid if(classes >=0 && classes <=6) numClasses = classes; } //other member function bool isHonorRoll(){ retunr GPA >= 3.0; } };
Picture example:
![]()
- Each term will have as follows: -> A definition on the term -> A code example some being in great detail if needed, for example a class example is going to be longer than a member variable. -> Lastly, a picture which in some way relates to the term but may also relate to other terms as well.