ENGTECH 1PR3 Study Guide - Fall 2018, Comprehensive Midterm Notes - Object-Oriented Programming, Member Variable, Harry Boyle Cricketer

135 views13 pages
ENGTECH 1PR3
MIDTERM EXAM
STUDY GUIDE
Fall 2018
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 13 pages and 3 million more documents.

Already have an account? Log in
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 13 pages and 3 million more documents.

Already have an account? Log in
Scanned by CamScanner
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 13 pages and 3 million more documents.

Already have an account? Log in
CLASSES / BASIC OOP LESSON 1
#include "stdafx.h"
#include <iostream>
using namespace std;
class student // definition of a class
{
private:
string m_studentName = " "; // "m_ is" for member variables so any varibale insied
class
// are known to any fucntion that
will be later on defined in class,
// those variable can be used in
any functions inside of class
int m_studentId = 0; // its to avoid confuion
bool m_enrolled = false;
public: // public indicates these variables aare able to be accessed from outside,
//private mean youu could not access those varibales from outside.
// constructors are used to
initialize variables in your objects,
// so it makes sense sense to pass
calues into a construcot wih are then
// used to intialize variables
inside of that consturcots
// should initialize all member
values
//constucotrs
student(); // constructor 1
student(string studentName); // constructor 2
student(string studentName, int studentId); // constructor 3
// function with the same name as the class is the constructor
// setters, modifies values of vaiables, mutator
void setStudentName(string studentName){m_studentName = studentName;} // inline
func where func in defined inside the class not outside}
void setStudentId(int studentId) { m_studentId = studentId; }
void setEnrolled(bool enrolled) { m_enrolled = enrolled; }
// getters, accessor, gets value
string getStudentName() {return m_studentName; }
int getStudentId() { return m_studentId; }
bool getEnrolled() { return m_enrolled; }
// create a func that enrolls student
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 13 pages and 3 million more documents.

Already have an account? Log in

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