Create a function to print out all the data for the Student. Remember to prototype this function and use outside of a class function.
#include <iostream>
#include <string>
using namespace std;
class Student
{
protected:
string firstName;
string lastName;
double averageGrade;
public:
Student() {};
Student (string _firstName, string _lastName, double _averageGrade)
{
firstName = _firstName;
lastName = _lastName;
averageGrade = _averageGrade;
}
void printInfo();
~Student() {};
};
void Student::printInfo()
{
cout << firstName << endl;
cout << lastName << endl;
cout << averageGrade << endl;
}
int main()
{
Student s = { "John", "Patterson", 60.5 };
s.printInfo();
return 0;
}
Comments
Leave a comment