I'm new to C++ and stuck on a problem. I want class Admin to be able to create new objects of the Student class and add the objects to an array that contains all students' info. How can I do that in the Admin class?
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class Student
{
public:
int SSN_LENGTH = 9, MIN_NAME_LEN = 1, MAX_NAME_LEN = 40;
string DEFAULT_NAME = "no name", DEFAULT_SSN = "000000000";
private:
string studentName, SSN;
public:
// constructor declarations
Student();
Student( string studentName, string SSN);
// Accessors
string getSSN(){ return SSN; }
string getStudentName(){ return studentName; }
// Mutators
bool setSSN(string SSN);
bool setStudentName(string studentName);
};
class Admin
{
private:
static const int Student_MAX_SIZE = 100000;
public:
bool addStudent (string studentName, string SSN);
};
std::vectorinstead. I don't see any function namedAdminwhat are you exactly talking about?Studentvariable. That is, create aStudent, and then change it, perhaps by passing anotherStudentto it. This is a necessary step on the way to storing aStudentin a container.vector, as that is what it is designed for.