Question: Please note , you are required to include the following when you use g++ to compile: -pedantic Log on to the Linux server. In a

Please note, you are required to include the following when you use g++ to compile: -pedantic

Log on to the Linux server.

In a different directory than the one used for project #2, create four files:

Long.h

Long.cpp

LongMain.cpp

Makefile

In Long.h:

#ifndef _LONG_H_

#define _LONG_H_

#include

using namespace std;

class Long

{

unsigned long long _n;

bool _ispos;

public:

Long();

Long(long long);

Long( const Long& );

~Long();

Long& operator= ( const Long& );

Long& operator+= ( const Long& );

Long& operator-= ( const Long& );

Long& operator*= ( const Long& );

Long& operator/= ( const Long& );

Long& operator%= ( const Long& );

Long& operator<<= ( const Long& );

Long& operator>>= ( const Long& );

friend ostream& operator<< ( ostream&, const Long& ); //must display the sign

friend istream& operator>> ( istream&, Long& ); //reads what operator<< writes

Long operator+ (const Long& ) const;

Long operator+ (long long) const;

friend Long operator+ (long long, const Long&);

Long operator- (const Long& ) const;

Long operator- (long long) const;

friend Long operator- (long long, const Long&);

Long operator* (const Long& ) const;

Long operator* (long long) const;

friend Long operator* (long long, const Long&);

Long operator/ (const Long& ) const;

Long operator/ (long long) const;

friend Long operator/ (long long, const Long&);

Long operator% (const Long& ) const;

Long operator% (long long) const;

friend Long operator% (long long, const Long&);

Long operator<< (const Long& ) const;

Long operator<< (long long) const;

friend Long operator<< (long long, const Long&);

Long operator>> (const Long& ) const;

Long operator>> (long long) const;

friend Long operator>> (long long, const Long&);

Long operator++ (int); //post

Long operator-- (int); //post

Long& operator++ (); //pre

Long& operator-- (); //pre

Long operator- () const;

Long operator+ () const;

bool operator== (const Long& ) const;

bool operator== (long long) const;

friend bool operator== (long long, const Long&);

bool operator< (const Long& ) const;

bool operator< (long long) const;

friend bool operator< (long long, const Long&);

bool operator!= (const Long& ) const;

bool operator!= (long long) const;

friend bool operator!= (long long, const Long&);

bool operator> (const Long& ) const;

bool operator> (long long) const;

friend bool operator> (long long, const Long&);

bool operator<= (const Long& ) const;

bool operator<= (long long) const;

friend bool operator<= (long, const Long&);

bool operator>= (const Long& ) const;

bool operator>= (long long) const;

friend bool operator>= (long long, const Long&);

};

#endif

In Long.cpp, implement these member functions. You must make sure that you never have a negative zero. You must not use any built-in functions

YOU MUST implement the functions in your .cpp file in the same order as I have listed them in the .h file

For the comparison operator you must implement two and only two of them directly:

bool operator== (const Long& ) const;

bool operator< (const Long& ) const;

All other comparison operators must be implemented in terms of these two. For example:

bool operator!= (const Long& L ) const

{

return !(*this == L);

}

All binary arithmetic operators must be implemented in terms of the corresponding immediate operators, i.e.,

Long operator+ (const Long& ) const;

Must be implemented in terms of

Long& operator+= (const Long& );

Note on the shift operators: ULONG_LONG_MAX contains 20 digits; shifting by a number 20 or larger results in a value that is out-of-range (<<) or zero(>>). Recall that shifting is the same as multiplying or dividing by 2, but much faster. You must not implement these by using multiplication or division.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!