i have a project with instructions stating project 3 static stack create an array of 5188980
I have a project with instructions stating: Project 3 Static Stack Create an array of student records (at least 15) and put all the related student records information in an array like Project 1: Student Id, Name, Address and average of test scores and a Pointer for Test Scores (at least 10 scores). -Display the student records in the array (do not display pointers). -Push all student records from the array to a static stack. -Pop 5 student records from the stack and display the popped records. -Display the remaining student records in the static stack.
My program wont let me declare an array of student records and an error message keeps popping up stating “Description Resource Path Location Type no matching function for call to 'student::student()' Project3(2).cpp /Project3(2)/src line 12 C/C++ Problem”. All i need to do is create the array of student records and then push those records onto a stack however im having trouble implementing the push function that pushes a student object. Here is what i have so far in my program containgin my main cpp, StaticStack.h, student.cpp,student.h:
main cpp:
#include
#include “student.cpp”
#include “StaticStack.h”
using namespace std;
int main() {
student StudentRec[15];
staticStack studentStack(15);
StudentRec[0].setName(“Mary”);
StudentRec[1].setName(“James”);
StudentRec[2].setName(“Adam”);
StudentRec[3].setName(“Phillip”);
StudentRec[4].setName(“Haley”);
StudentRec[5].setName(“Marc”);
StudentRec[6].setName(“Payton”);
StudentRec[7].setName(“Rob”);
StudentRec[8].setName(“Chris”);
StudentRec[9].setName(“Holly”);
StudentRec[10].setName(“Morgan”);
StudentRec[11].setName(“Carson”);
StudentRec[12].setName(“Zac”);
StudentRec[13].setName(“Logan”);
StudentRec[14].setName(“Sarah”);
//set Testavg of students
StudentRec[0].setTestavg();
StudentRec[1].setTestavg();
StudentRec[2].setTestavg();
StudentRec[3].setTestavg();
StudentRec[4].setTestavg();
StudentRec[5].setTestavg();
StudentRec[6].setTestavg();
StudentRec[7].setTestavg();
StudentRec[8].setTestavg();
StudentRec[9].setTestavg();
StudentRec[10].setTestavg();
StudentRec[11].setTestavg();
StudentRec[12].setTestavg();
StudentRec[13].setTestavg();
StudentRec[14].setTestavg();
//set Address of students
StudentRec[0].setAddress(“123 WonderWorld Dr”);
StudentRec[1].setAddress(“123 Craddock Ave”);
StudentRec[2].setAddress(“123 Ashley St”);
StudentRec[3].setAddress(“123 Ranch Rd”);
StudentRec[4].setAddress(“123 Hughson Dr.”);
StudentRec[5].setAddress(“123 Hopkins St”);
StudentRec[6].setAddress(“123 Thorpe Ln”);
StudentRec[7].setAddress(“123 Guadalupe St”);
StudentRec[8].setAddress(“123 Frost Ln”);
StudentRec[9].setAddress(“123 Chisolm St”);
StudentRec[10].setAddress(“123 Gordon St”);
StudentRec[11].setAddress(“123 Hunter Rd”);
StudentRec[12].setAddress(“123 Holland Rd”);
StudentRec[13].setAddress(“123 Aquarena Rd”);
StudentRec[14].setAddress(“123 Uhland Rd”);
//randomly generated student IDs
for (int i = 0; i
StudentRec[i].setId();
}
cout
cout
cout
cout
for (int i = 0; i
cout
}
for (int i = 0; i
studentStack.push(StudentRec[i]);
}
return 0;
}
///////////////////////////////////////////////////////////
StaticStack.h:
/*
* StaticStack.h
*
* Created on: Jul 20, 2017
* Author: Quinton
*/
#ifndef STATICSTACK_H_
#define STATICSTACK_H_
#include “student.h”
using namespace std;
class staticStack
{
private:
student *stackArray;
public:
int stackSize;
int top;
//Constructor
staticStack(int);
// Copy constructor
staticStack(const staticStack &);
//Destructor
~staticStack();
//stack operations
void push (student);
void pop (student &);
bool isFull() const;
bool isEmpty() const;
};
staticStack::staticStack(int size){
stackArray = new student[size];
stackSize = size;
top = -1;
}
staticStack::staticStack(const staticStack &obj){
//create the stack array
if(obj.stackSize > 0)
stackArray = new student[obj.stackSize];
else
stackArray = nullptr;
//copy the stackSize atribute.
stackSize = obj.stackSize;
//Copythe stack contents
for (int count = 0; count
stackArray[count] = obj.stackArray[count];
}
//set the top of the stack
top = obj.top;
}
//destructor
staticStack::~staticStack(){
delete [] stackArray;
}
void staticStack::push(student x){//??
if (isFull()){
cout
}
else{
top++;
stackArray[top]= x ; //??
}
}
void staticStack::pop(student &num){
if (isEmpty()){
cout
}
else{
num = stackArray[top];
top–;
}
}
bool staticStack::isFull() const {
bool status;
if (top == stackSize – 1){
status = true;
}else{
status = false;
}
return status;
}
bool staticStack::isEmpty() const{
bool status;
if(top == -1){
status = true;
}else{
status = false;
}
return status;
}
#endif /* STATICSTACK_H_ */
//////////////////////////////////////
student.cpp:
#include
#include //For rand and srand
#include //For the time function
#include “student.h”
using namespace std;
void student::setName(string name) { //creates student name
sName = name;
}
string student::getName() { //returns student name
return sName;
}
void student::setAddress(string address) { //sets students address
sAddress = address;
}
string student::getAddress() { //returns students address
return sAddress;
}
void student::setId() {
int MIN_VALUE = 1000;
int MAX_VALUE = 9999;
sId = (rand() % (MAX_VALUE – MIN_VALUE + 1)) + MIN_VALUE;
}
int student::getId() {
return sId;
}
//this function creates a test avg for each student
void student::setTestavg() {
int MIN_VALUE = 60;
int MAX_VALUE = 100;
int gradeTotal;
int tests[10];
testScores = tests;
for(int i = 0; i
grade = (rand() % (MAX_VALUE – MIN_VALUE + 1)) + MIN_VALUE;
tests[i] = grade;
}
for (int i = 0; i
gradeTotal += *(testScores + i);
}
avgTest = gradeTotal/10;
}
int student::getTestavg(){
return avgTest;
}
///////////////////////////////////
student.h:
/*
* student.h
*
* Created on: Jul 21, 2017
* Author: Quinton
*/
#ifndef STUDENT_H_
#define STUDENT_H_
using namespace std;
class student {
private:
int sId;
string sName, sAddress;
int grade;
int avgTest;
int *testScores;
public:
student(string n,string addr, int average, int id){
sName = n;
sAddress = addr;
avgTest = average;
sId = id;
}
void setName(string);
string getName();
void setAddress(string);
string getAddress();
void setId();
int getId();
void setTestavg();
int getTestavg();
};
#endif /* STUDENT_H_ */