ENGTECH 1PR3 Lecture Notes - Lecture 1: Member Variable

27 views3 pages

Document Summary

Classes / basic oop lesson 1 string m_studentname = " "; // "m_ is" for member variables so any varibale insied. // so it makes sense sense to pass int m_studentid = 0; // its to avoid confuion bool m_enrolled = false; //private mean youu could not access those varibales from outside. // getters, accessor, gets value string getstudentname() {return m_studentname; } int getstudentid() { return m_studentid; } bool getenrolled() { return m_enrolled; } student(string studentname, int studentid); // constructor 3. // function with the same name as the class is the constructor void setstudentid(int studentid) { m_studentid = studentid; } void setenrolled(bool enrolled) { m_enrolled = enrolled; } // should initialize all member void setstudentname(string studentname){m_studentname = studentname;} // inline. // specifies a student name which is going to be. //student id is m_studentname = studentname; // initilaize member varibale with the value passed m_studentid = 10; void enrollstudent(); m_studentname = "default "; m_studentid =9999;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents