Create a class called Student . The Student class will have 4 private member var
ID: 3535689 • Letter: C
Question
Create a class called Student. The Student class will have 4 private member variables (string name, int id, int *test, int nume). Also have the following member functions, all of them will be public except makeArray() which will beprivate. (Void makeArray(), Student(), Student(int n), Student(string nm,int i, int n), void setName(string nm)) void setID(int i), void setScore(int i, int s), string getName() const, int getID() const, void showScore(),void display(),~Student(). Also In the main , create 3 students. Student a should call the default constructor. Student b should call the constructor with 1 parameter and pass in 4. Student c should call the constructor with 3 parameters and pass in "Joe", 40 and 5. Call the necessary set functions and finally call the display function for each of the student objects. Look at the output to figure out which set functions you need to call and what values you need to pass in.
Explanation / Answer
#include<iostream.h>
#include<conio.h>
class Student
{
string name;
int id , *test,nume;
void makeArray();
{
int size = nume;
int *studentArray;
studentArray = new int[num];
test == studentArray;
}
public:
Student()
{}
Student(int n)
{
nume=n;
}
Student(string nm,int i,int n)
{
name=nm;
id=i;
nume=n;
}
void setName(string nm)
{
name=nm;
}
void setId(int i;)
{
id=i;
}
void setScore(int i ,int s)
{
test[i]=s;
}
string getName() const
{
return name;
}
int getID() const
{
return id;
}
int showScore() const
{
for(int count = 0; count < Student::num; count++)
{
cout << "Test " << count << "had a score of " << test[count] << endl;
}
}
void display()
{
cout<<" Name:"<<getName();
cout<<" ID:"<<getID();
cout<<" Score:"<<showScore();
}
~Student()
{}
}
void main()
{
Student a(),b(4),c("Joe",40,5);
a.setName("Billy");
a.setID(3);
a.setScore(0,60);
a.setScore(1,80);
a.setScore(2,70);
b.setName("Sinky");
b.setID(6);
b.setScore(0,65);
b.setScore(1,75);
b.setScore(2,85);
b.setScore(4,95);
c.setName("Humpy");
c.setID(8);
c.setScore(0,68);
c.setScore(1,78);
c.setScore(2,88);
c.setScore(3,98);
a.display();
b.display();
c.dipslay();
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.