Answer to Question #327667 in C++ for Amy

Question #327667

Create a function to print out all the data for the Student. Remember to prototype this function and use outside of a class function.

1
Expert's answer
2022-04-12T16:15:39-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS