[Solved] CSCI804 Lab4-Overloading operators

$25

File Name: CSCI804_Lab4-Overloading_operators.zip
File Size: 320.28 KB

SKU: [Solved] CSCI804 Lab4-Overloading operators Category: Tag:
5/5 - (1 vote)

Task: Overloading operators

We will reuse some definitions and implementations of the class BigInteger defined in the lab 3 for this task.

Define the class BigInteger in a file BigInteger.h and implement its member functions in a file BigInteger.cpp that can be used to store a large positive integer. The class contains two data members: a pointer of short integer and the size of the dynamic short integer array. Define the following member functions:

  • The default constructor;
  • An initialization constructor initializes a BigInteger instance with a char array, in which all elements are decimal digits.
  • The copy constructor makes a deep copy from a BigInteger instance.
  • The destructor;
  • Define insertion operator and extraction operator for the class.
  • Define assignment operator for the class that makes a deep copy from a BigInteger object.
  • Define addition operator that returns a BigInteger object of addition result. Do not change the operands.
  • Define multiplication operator for the class that returns a BigInteger object of multiplication result. Do not change the operands.
  • Define comparison operator equals to that returns the value true if two BigInteger objects contain the same values.

Write the driver program include main function in a file lab4Main.cpp to declare instances of BigInteger, test all the overloading operators defined above.

Be careful not to submit the solutions for the lab 4 task.

Compile the files by

g++ o task4 lab4Main.cpp BigInteger.cpp

And execute it. Your program should be run like the following example (Red data means input from keyboard)

./task4

Input a big integer for bi1: 567239745104730482394650169432

Input a big integer for bi2: 882323456205024318310561095 Initial bi3=1234567890

bi3 = bi1 + bi2 = 568122068560935506712960730527 bi3 = bi1 * bi2 = 500488932397662823233748695498247943120741026136737448040 bi1 is not equal to bi2 bi3 = bi2 = 882323456205024318310561095 bi3 is equal to bi2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCI804 Lab4-Overloading operators
$25