Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Where am I going wrong? C + + is still giving me an error C 2 0 3 3 9 'printStudentInfo':is not a member of

Where am I going wrong?
C++ is still giving me an error C20339 'printStudentInfo':is not a member of 'Student'
My Student.H
#ifndef Student_H
#define Student_H
#include
using namespace std;
class Student{
private:
std:string name;
std::string id;
int numTests;
double* scores;
public:
//Constructors
Student(int numTests);
Student(std::string name, std::string id, int numTests);
//Deconstructor
~Student();
// Mutator Functions
void setName(std::string name);
voidsetId(std::string id);
void setScore(int testNum, double score);
//Accessor functions
std::string getName();
std::string getId();
double getScore(int n);
int getNumTests();
void printStudentInfo();
};
#endif
//Student.cpp
#include "Student.H"
#include
// 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;
}
}
int Student::getNumTests(){
return numTests;
}
void Student::printStudentInfo(){
std::cout << "Name: "<< name <<", ID: "<< id << std::endl;
for (int i =0; i < numTests; ++i){
std::cout << "Test "<< i +1<<" Score: "<< scores[i]<< std::endl;
}
}
//Lab.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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago