[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Overloading HugeInteger

Asked by rebelcowgirl_73 in C++ Programming Language

Tags: C++

I am back LOL...  I am trying to overload a previous version of HugeInteger.  All methods worked and such before attempt to overload.  I am gonna go threw this bit by bit.  Since I was suppose to overload every single function in my already completed work, i figured I would start with one I thought I kind of understood.  HA HA what a joke that was.  Here is my attempt at overloading output <<  However I get four different errors.  I have included the .h file and all methods up to the output << method hoping someone can tell me why I am getting these errors.
.h file

class OLHugeInteger
{
      friend ostream &operator<<(ostream &, const OLHugeInteger &);

public:
      OLHugeInteger();      //constructor
      void input();      
      void copyBigNumber(int [], const int []) const ;

      OLHugeInteger add(const OLHugeInteger &) const;
      OLHugeInteger subtract(const OLHugeInteger &) const;
      OLHugeInteger multiply(const OLHugeInteger &) const;
      
      OLHugeInteger multiplySub(int) const;
      OLHugeInteger opposite(const OLHugeInteger &) const;
      

      bool equalTo(const OLHugeInteger &) const;
      bool notEqualTo(const OLHugeInteger &) const;
      bool greaterThan(const OLHugeInteger &) const;
      bool greaterThanOrEqualTo(const OLHugeInteger &) const;
      bool lessThan(const OLHugeInteger &) const;
      bool lessThanOrEqualTo(const OLHugeInteger &) const;
      bool isZero() const;

private:
      int const arraySize;      //const array size
      bool isNegative;      //determines if array of integers is negative
      char line[41];
      int bigNumber[40];      //array to hone users inputted integer
      void copyBigNumber(int [], const int []);      //creates copy of bigNumber[]


};      //End class OLHugeInteger

#endif

.cpp up to output<<
#include <iostream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;

#include <string>      //for string length (strlen)

#include "OLHugeInteger.h"      //include definition of class HugeInteger

int inputSize = 0;      //default size of users integer

//default constructor const arraySize = 40
OLHugeInteger::OLHugeInteger() :arraySize(40)
{
      for (int loopSize = 0; loopSize < arraySize; loopSize++)
            //initialize array with 0's
            bigNumber[loopSize] = 0;      
      
      //set bool isNegative to false
      isNegative = false;

}//end constructor

void OLHugeInteger::input()
{
      //characters read in to hold integer values
    char line[41];      
     
      //ask for usre input and make sure no more than 40 digits where entered
      //if more than 40 digits are entered, drop extra from bigNumber
      cout << "Enter Huge Integer (Max: 40 digits, extra digits will be dropped!): " << endl;
      cin.getline(line, sizeof line);
      cin.sync();
      cin.clear();

    //determine size of users integer
      inputSize = strlen(line);      

      //check for negative integer value and set bool
      if (inputSize > 0)      
      {
            int negative = '-';
            if (line[0] == negative)
                  isNegative = true;
      }

      //set negative to zero
      if (isNegative)
            line[0] = '0';

      //check that all digits entered where integer values
      for (int loopSize = 0; loopSize < inputSize; loopSize++)
            if (!isdigit(line[(inputSize - 1) - loopSize]))
            {
                  cout << "Not all digits entered where integers.  Array initialized to zero" << endl;
                  return;
            }

      //add digits to array bigNumber
      for (int loopSize = 0; loopSize < inputSize; loopSize++)
            //subtract ASCII value for '0' to get raw value store digits at
            //end of 40 digit array all non initialized parts of array stay a 0
            bigNumber[(arraySize - 1) - loopSize] = line[(inputSize - 1) - loopSize] - '0';
            
}//end input function

ostream &operator<<(ostream &output, const OLHugeInteger &bigNumber2)
{
      // Display negative sign if isNegative is set.
      if (isNegative)
            output << '-';
      
      //if array isZero then print a single zero
      if(isZero())
            output << '0';
      
      bool leadingZero = true;
      
      //avoid printing all leading zero'
      for (int digitIndex = 0; digitIndex < arraySize; digitIndex++)
      {
            int digit = bigNumber[digitIndex];
            //if it is not a zero, print it, and set leadingZero to false;
            if (digit != 0)
            {
                  leadingZero = false;
                  output << digit;
            }//end if
            else
                  //else if digit is zero, print only if not leading
                  if (!leadingZero)
                        output << digit;
                  
      }//end for
      return output;
     
}//end output function
[+][-]04/29/08 06:28 PM, ID: 21467522Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C++ Programming Language
Tags: C++
Sign Up Now!
Solution Provided By: lwinkenb
Participating Experts: 3
Solution Grade: A
 
[+][-]04/29/08 06:00 PM, ID: 21467425Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 06:12 PM, ID: 21467464Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 06:20 PM, ID: 21467490Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/29/08 06:24 PM, ID: 21467506Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/29/08 06:26 PM, ID: 21467512Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 06:40 PM, ID: 21467565Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 06:51 PM, ID: 21467588Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/29/08 07:00 PM, ID: 21467610Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 07:09 PM, ID: 21467639Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/29/08 07:10 PM, ID: 21467641Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/29/08 07:16 PM, ID: 21467668Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 07:32 PM, ID: 21467742Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/29/08 07:39 PM, ID: 21467762Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 07:43 PM, ID: 21467773Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 07:57 PM, ID: 21467813Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/29/08 07:59 PM, ID: 21467817Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 07:59 PM, ID: 21467818Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/29/08 08:00 PM, ID: 21467821Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/29/08 08:02 PM, ID: 21467825Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 08:07 PM, ID: 21467839Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/29/08 08:27 PM, ID: 21467887Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 08:36 PM, ID: 21467922Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 08:43 PM, ID: 21467943Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04/29/08 08:49 PM, ID: 21467959Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 09:17 PM, ID: 21468037Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 09:24 PM, ID: 21468060Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/29/08 09:38 PM, ID: 21468114Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/02/08 01:03 PM, ID: 21489652Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/03/08 05:40 AM, ID: 21492122Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628