Я пишу школьный проект, в котором мне не разрешено использовать какие-либо внешние библиотеки (что действительно отстой, поскольку мне приходится создавать динамический массив, а не вектор в соответствии с требованиями проекта). Я считаю, что проблема в том, что когда я запускаю конструктор для своего динамического массива, он не присваивает моему массиву емкость. Беллоу — мой конструктор.
Код: Выделить всё
Roster::Roster(int capacity) {
capacity = capacity;
size = 0;
Student* classRosterArray = new Student[capacity];
Код: Выделить всё
Roster::Roster(int capacity) {
this->capacity = capacity;
this->size = 0;
this->classRosterArray = new Student * [capacity];
main.cpp
Код: Выделить всё
#include
#include "degree.h"
#include "student.h"
#include "roster.h"
using namespace std;
int commaSpotStart = 0;
int commaSpotEnd;
int commaDist;
string scrubbedID;
string scrubbedFName;
string scrubbedLName;
string scrubbedEmail;
string scrubbedAge;
string scrubbedD1;
string scrubbedD2;
string scrubbedD3;
string scrubbedDegree;
int convAge;
int convD1;
int convD2;
int convD3;
DegreeProgram convDegree;
void scrub(string stringStudent) {
commaSpotStart = 0;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
scrubbedID = stringStudent.substr(commaSpotStart, commaSpotEnd);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
commaDist = commaSpotEnd - commaSpotStart;
scrubbedFName = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
commaDist = commaSpotEnd - commaSpotStart;
scrubbedLName = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart); commaDist = commaSpotEnd - commaSpotStart;
scrubbedEmail = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
commaDist = commaSpotEnd - commaSpotStart;
scrubbedAge = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
commaDist = commaSpotEnd - commaSpotStart;
scrubbedD1 = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
commaDist = commaSpotEnd - commaSpotStart;
scrubbedD2 = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
commaDist = commaSpotEnd - commaSpotStart;
scrubbedD3 = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
commaSpotEnd = stringStudent.find(",", commaSpotStart);
commaDist = commaSpotEnd - commaSpotStart;
scrubbedDegree = stringStudent.substr(commaSpotStart, commaDist);
commaSpotStart = commaSpotEnd + 1;
}
void printStringStudent() {
int i = 0;
std::cout
Источник: [url]https://stackoverflow.com/questions/78158431/program-is-throwing-exception-think-it-is-due-to-dynamic-array-not-constructing[/url]