Project2 - Thomas Nanke CIS 200-001 CIS 200L-001...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Thomas Nanke CIS 200-001 CIS 200L-001 Programming Project #2 Operator Overloading, Friend, File I/O and List 3/5/08
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Question 1: The Machine type that I used for this program is the PC with Microsoft Windows XP Professional as the operating system. The compiler type that I used is the Microsoft Visual 6.0 Compiler. Here is my source code without comments because the comments make it look even sloppier in MS Word. I have my comments included in the .cpp file. #include<iostream> #include<string> #include<fstream> using namespace std; class Student { private: int Id; int FinalGrade; float Grade[4]; public: void setId(int x) { Id = x; }; void setGrade(float x[4]) { for(int count=0;count<4;count++) Grade[count] = x[count]; }; bool operator==(Student x) const { if (FinalGrade == x.FinalGrade) return true; else return false; } friend class Teacher; }; class Teacher {
Background image of page 2
private: int Id; float Salary; public: Student calculateGrade(Student a) { a.FinalGrade = a.Grade[0] + a.Grade[1] + a.Grade[2] + a.Grade[3]; return a; }; }; int main( ) { float g1[] = {10.0, 20.0, 25.0, 25.0}; float g2[] = {25.0, 20.0, 10.0, 25.0}; Student x, y; x.setGrade(g1); y.setGrade(g2); Teacher z; x = z.calculateGrade(x); y = z.calculateGrade(y); if(x==y)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Project2 - Thomas Nanke CIS 200-001 CIS 200L-001...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online