Test Question.

Using C++ Create a program that enables the creation of student objects. The objects should
contain two data members that store values for student name and fees paid. The
object should also have an overloaded version of the plus (+) operator which will be
used to calculate the total amount of fees for student objects created by your
program.
The program should enable the user specify the number of student objects to create
and create on the required number of objects.

Please assist with the actual code in C++.
It looks like you will need to define a 'Student' class and then give it a member function Student operator+(Student) to describe how two students are added. For details on operator overloading:

http://cplusplus.com/doc/tutorial/classes2/
(For general info on C++ classes, http://cplusplus.com/doc/tutorial/classes/)

As for creating a specified number of students, you will need a dynamically allocated array of student objects (Student* students), allocated using the new keyword.

http://cplusplus.com/doc/tutorial/dynamic/

PS: Sorry I've not provided any actual code, but the predominant view on here seems to be that it's best not just to give solutions to homework problems, but rather to provide information to help with the solution.
Last edited on
No need to apologise, i understand. Thanks for pointing & showing me the way.
Topic archived. No new replies allowed.