/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
#include <string>
#include <iostream>
using namespace std;
class Student
{
public:
string mName;
double mlibrary_Fine;
double mtuition_Fees;
//Default Constructor
Student();
//over-ridden constructor
Student(string, double, double);
//Copy constructor
Student(const Student&);
//Destructor
~Student();
//Assignment operator
Student& operator=(const Student&);
//To show the details of the student as output.
void showStudent();
//Method to calculate the total money.
double totalMoneyOwed(double, double);
//Method to enter the details of the student.
void enterDetails();
};
//Default constructor
Student::Student()
{
mName = "John";
mlibrary_Fine = 0.0;
mtuition_Fees = 0.0;
}
//Over-ridden constructor
Student::Student(string Name, double fines, double fees)
{
mName = Name;
mlibrary_Fine = fines;
mtuition_Fees = fees;
}
//Copy Constructor
Student::Student(const Student& otherStudent)
{
Student A;
mName = otherStudent.mName;
mlibrary_Fine = otherStudent.mlibrary_Fine;
mtuition_Fees = otherStudent.mtuition_Fees;
}
//Overloading the assignment operator.
Student& Student::operator=(const Student& anotherStudent)
{
mName = anotherStudent.mName;
mlibrary_Fine = anotherStudent.mlibrary_Fine;
mtuition_Fees = anotherStudent.mtuition_Fees;
return *this;
}
//Destructor
Student::~Student()
{
}
//Method to show details of the student.
void Student::showStudent()
{
cout << "Name of student = "<< mName << endl;
cout << "Library Fines = " << mlibrary_Fine << endl;
cout << "Fees = " << mtuition_Fees << endl;
}
//Method to calculate the total money owed by the student.
double Student::totalMoneyOwed(double libfine, double fees)
{
double total;
total = libfine + fees;
return total;
}
//Method to change the member variables of the student object.
void Student::enterDetails()
{
cout << "What is the name of the student?" << endl;
getline(cin, mName);
cout << "What is the total fines for the student?" << endl;
cin >> mlibrary_Fine;
cout << "What are the total fees for the student ?" << endl;
cin >> mtuition_Fees;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
Student A("Dude", 1.0, 1.0);
A.showStudent();
A.enterDetails();
A.showStudent();
return 0;
}