Hi,
I am trying to design a vector within a vector within a vector. For example, a school has 3 floors, each floor has 5 classrooms, each classroom has 20 students, each student has a last name and a first name. I know how to create a vector for floors and classrooms. I am having a hard time how it works with the student's names. How do I assign peter pan to floor 2, room3, for example?
Thanks for helping!
///floor 1
v[1]:[[classroom1][student1], [classroom2][student2], [classroom3][student3], [classroom3][student3]....]
`#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
///*********************************************
///
/// Student Class
///
///*********************************************
class Student
{
private:
string lastName;
string firstName;
public:
/// default constructor
Student() {}
/// default destructor
~Student() {}
/// getter functions
string getLastName() const { return lastName; }
string getFirstName() const { return firstName; }
/// setter functions
void setLastName(string ln) { lastName = ln; }
void setFirstName(string fn) { firstName = fn; }
};
///*********************************************
///
/// School Class (base class)
///
///*********************************************
class School
{
protected:
Student student;
vector< vector<int> > classRooms;
public:
/// constructor
School(int floor, int rooms, Student& s)
{
/// set number of floors and rooms, init students' name to empty string
classRooms.resize(floor, vector<int>(rooms, 0));
///
classRooms.resize(floor, vector<Student>(????));
}
};
/// main program
int main()
{
/// some function that changes student's first and last names.
}`