A. Create a class named Teacher that holds a Teacher’s first and last names and the grade
level the Teacher teaches. Include a constructor function that uses default first and last
names, such as “ZZZZZZZ” and a default grade level, such as 0, when no arguments are
provided.
B. Create a class named Student that hold’s a Student’s first and last names. Include a
constructor function that uses default first and last names, such as “ZZZZZZZ,” when no
names are provided.
C. Create a class named Classroom. A Classroom holds a Teacher and an array of 35
Student objects.
D. Create a class named School. A School contains an array of 100 Classroom objects.
(This class is being designed to be a very large class, to more quickly demonstrate running
out of memory.)
1
Expert's answer
2015-02-20T08:26:43-0500
Program: #include<iostream> #include<string> #define MAX_LEN 100 using namespace std; class Teacher { private: string firstName; string lastName; int grade; public: Teacher(string first="ZZZZZZZ",stringlast="ZZZZZZZ", int gr=0); }; Teacher::Teacher(stringfirst,string last, int gr) { firstName=first; lastName=last; grade=gr; } class Student { private: string firstName; string lastName; public: Student(stringfirst="ZZZZZZZ",string last="ZZZZZZZ"); }; Student::Student(stringfirst,string last) { firstName=first; lastName=last; } class Classroom { private: Teacher teacher; Student students[35]; }; class School { private: Classroom classes[100]; }; int main() { School *mySchool; mySchool=new School; if(mySchool==NULL) cout<<"Out of memory"; else cout<<"We can use so big pieof memory!"; return 0; }
Comments
Leave a comment