Image

Imagecgs3408h4x wrote in Imagecpp 😐nerdy

Listens: George Straight- I Hate Everything

Am I Retarded?

Hey y'all, I am working on the project with the array of integers yaddah. The one where I store each integer in an element of an array.

So I figured out what I was going to do for my storage, I just store everything as an integer. And the string that can be passed in just gets converted to integers and then stored. Funny thing, the string is stored just how the number is represented on paper, and then integers are stored in reverse order with the last digit being a[0].

Anyhoo, I am doing the operator overloads for majority of the existing operators. There is one that is giving me a particulary hard time. I want to literally pull my hair out because I dont feel that there is anything wrong with this syntatically. However, VS 6.0 C++ tends to beg otherwise.

This declaration is declared outside of any protection level (public, private) and is a friend of the class.
friend ostream& operator<< (ostream&, const MyInt&);
So there I am trying to overload the '<<' operator. However, when I compile this interface and implementation file along with my main program file that makes objects out of this stuff, I get the following error:
c:\documents and settings\nicholas c. hohman\my documents\cop3330 assignments\assignment7\myint\myint.h(22) : error C2143: syntax error : missing ';' before '&'

Like several dozen times. I was wondering if anyone can see a problem with that damn declaration, for I see none. Furthermore, I am looking into writing the definition of it, but this is all I have.

ostream& operator<< (ostream& p, const MyInt& mI)
{
     int i;
     if (mI.isInt)
          for (i = 0; i < mI.currentSize; i++)
               p << myInt[i];
     else if (!mI.isInt)
          for (i = 0; i < mI.currentSize; i++)
               p << I2C(myInt[i]);
     return p;
}


Where isInt is a boolean flag set in either constructor that tells whether the object created represents integer data or character data in the array.
CurrentSize is the amount of good data occuping elements in the array.

If I am retarded, please just blatently say it, and then offer any advice. Thank you all.