(50 points)





The purpose of this assignment is to practice developing an ADT with overloaded operators and separate compilation. For this project we will be developing an ADT for integers.




First create a separate directory for this assignment



mkdir proj7



cd proj7





Then copy the my_int.h and main.cc from my directory intoproj7 directory.



cp /home/kmgsubm/f14_2400/proj7/* .


You may add other functions, but DO NOT change any functions or function names in the my_int.h class

 



Before you begin working on this program please look at Money.h, Money.cc and main.cc on Blackboard. You can also copy these files from my directory. cp /home/kmgsubm/f14_2400/week13/Money/* .




Class Description

 





  • A default constructor – initialize the value to zero



  • A constructor that takes one argument for the initial value of val.



  • A set function set the value to the incoming argument.



  • An extraction operator (>>) that allows user to enter the integer from the keyboard or from a data file.



  • An insertion operator (<<) that outputs the integer to the screen or to an output file.



  • One accessor function for the private member variable.

 



 



Overload the operator +, -, %, *,<=, >> and << as friend functions of the class and increment and decrement operators as member functions of the class. Also *, / and == operators and non-member functions of the class.



 



For this program input is from the keyboard and output is written to the screen.



 



Finally you have to make sure that you have 3 files in your proj6 directory.







  • The interface file (my_int.h)

 



 





  • The implementation file consists of all the function definitions of the class. And this file will be saved as a my_int.cc file. You have to include your interface file in your implementation file along with other include directives in the

 



following manner: #include “my_int.h”



This file can contain short (one- or two-line) comments for each function and header block with you name, date etc.







  • Your main function (application file) saved as a .cc file.

 



 



When you are compiling you have to include both .cc files. Do not compile the .h file.





g++ -Wall main.cc my_int.cc





OR g++ -Wall *.cc




Note: Before submitting the program make sure that you are in the correct directory and it contain 3 files. (interface file implementation file, application file)



/home/kmgsubm/bin/2400submit -p 7



 



Also turn in your implementation file with a cover sheet showing name/date/time on Tuesday December 3rd




Scoring for Assignment 7



- Documentation – header comments (for implementation) , style etc. - 2 pts - Functions - 45 points



- Electronic submission (3 files) and source code (implementation file) – 3 pts

 

    • 12 years ago
    Complete A++ Solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      answer.zip