67 155
Assignments Done
99,4%
Successfully Done
In November 2018

Answer to Question #50783 in C++ for zexy

Question #50783
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.)
Expert's answer
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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions