Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I fix this error? class Student has no member printStudentInfo here is my Student.H file#ifndef Student _ H #define Student _ H #include

How do I fix this error? "class "Student" has no member "printStudentInfo"
here is my Student.H file#ifndef Student_H
#define Student_H
#include
#include
using namespace std;
const double DEFAULT_SCORE =0.0;
class Student
{
private:
std::string name;
std::string id;
int numTests;
double* scores;
public:
Student(int numTests);
Student(std::string name, std::string Id, int numTests);
~Student();
// Mutator functions
void setName(std::string name);
void setId(std::string id);
void setScore (int testNum, double score);
// Accessor functions
std::string getName();
std::string getId();
double getScore(int n);
int getNumTests();
};
#endif
Student.cpp
#include "Student.H""
// Constructors
Student::Student(int numTests){
this->numTests = numTests;
scores = new double[numTests];
}
Student::Student(std::string name, std::string id, int numTests){
this->name = name;
this->id = id;
this->numTests = numTests;
scores = new double[numTests];
}
// Destructor
Student::~Student(){
delete[] scores;
}
// Mutator functions
void Student::setName(std::string name){
this->name = name;
}
void Student::setId(std::string id){
this->id = id;
}
void Student::setScore(int testNum, double score){
if (testNum >=0 && testNum < numTests){
scores[testNum]= score;
}
}
// Accessor functions
std::string Student::getName(){
return name;
}
std::string Student::getId(){
return id;
}
double Student::getScore(int n){
if (n >=0 && n < numTests){
return scores[n];
}
else {
return -1; // or any appropriate value to indicate error
}
}
int Student::getNumTests(){
return numTests;
}
and my main.cpp#include
#include "Student.h"
using namespace std;
int main()
{
Student s1("John Doe", "12345",3), s2(2);
s1.setScore(0,89);
s1.setScore(1,97);
s1.setScore(2,91);
s2.setName("Buzz");
s2.setId("02468");
s2.setScore(0,82);
s2.setScore(1,85);
//get students' first test score
cout << "Name: "<< s1.getName()<<" Score: "<< s1.getScore(0)<< endl;
cout << "Name: "<< s2.getName()<<" Score: "<< s2.getScore(0)<< endl;
//print students info
cout <<"
>>> Studdent 1<<<";
s1.printStudentInfo();
cout <<">>> Studdent 2<<<";
s2.printStudentInfo();
s1.setName("Joseph");
s1.setScore(1,100);
cout <<
"
>>> Studdent 1<<<";
s1.printStudentInfo();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Who did you wish to speak to?

Answered: 1 week ago

Question

3. Compute for the correct answer 3. Compute for the correct

Answered: 1 week ago

Question

What is polarization? Describe it with examples.

Answered: 1 week ago