Trying to use operator "==" to compare 2 objects of the same class
<p>I'm on a tight schedule and I'm running out of ideas on how to get this program to work. I'm quite new to c++ and programming in general and we are just now learning classes, overloaded operators, and a bunch of file operations, which we have to use in our program. It's quite lengthy. The program is basically testing the functionality of something similar to an mp3 player (ex. ipod). Here's the breakdown:  </p>

<p>1) We have to create two classes: Tsupod and Songs and all of the songs in the program will be stored in "list.dat". </p>

<p>2) We have read the list in binary mode, write out, read in when listing all the songs stored, and use file operations to find points in the file where we have to  find a song to be removed or to be moved around in the file...particularly when I'd have to code the function for the shuffle. </p>

<p>3) these are all done in five different files... And apparently, the reading in and writing out with reinterpret_cast does not work in linux systems, but it works for windows. </p>

<p>Here what i'm trying to do in my Songs class under public members... </p>

<pre><code>    //overloaded operator '==' ...
     bool operator ==( Songs&amp; b)
    {   
        if (strcmp(Title, b.Title) &gt; 1)
            return false;
        else if (strcmp(Artist, b.Artist) &gt; 1)
            return false;
        else if (size != b.size)
            return false;
        else
            return true;
    }

private:
    char Artist[30];
    char Title[30];
    int size;
};#endif // SONGS_H_INCLUDED
</code></pre>

<p>And here's the code TsuPod.cpp within the int tsupod::removeSong(string removeTitle, string emoveArtist) where I'm trying to implement it... the strings removeTitle and remove artist are from the function call in main: Pod.removeSong("blah", "blahblah");  where Pod is an object of class tsupod. song class is called in removeSong function where the artist and the titles get converted to character arrays. Flags are reset in songFile.</p>

<pre><code>for(int i = 0; i &lt; num_songs; i++)
{
    songFile.read(reinterpret_cast&lt;char*&gt;(&amp;info), sizeof(info));
    pos = sizeof(info) * count;
    songfile.seekp(pos - sizeof(info));

    if (S == info)
    {
        num_songs--;    
    }
    else
    {
        songFile.write(reinterpret_cast&lt;char*&gt;(&amp;info), sizeof(info));
        count++
    }
}
</code></pre>

<p>What i'm trying to do in this function is overwrite the data in the file so i wont have any gaps in the file that I will have to deal with later. I have also tried numerous ways to go about this...renaming the old file and then creating a new file with the old file name, or character arrays that will hold the information. Songs objects in this program are basically used as huge buffers to hold information which would then be stored into a file. </p>

<p>The MAIN ISSUE that I have is that I'm trying to compare two objects of the same class. "S" and "info". Before saying anything I AM NOT ALLOWED TO USE ARRAYS for this particular assignment because the whole point is for students like me is spend about 26 hours plus on this according to my professor practicing file operations. I'm also pretty sure that it's my overloaded == operator that isn't working because it would always skip over the conditional every iteration. It's probably something very simple that i'm missing just like that one time I spent 3 hours looking for a missing semicolon. HOW CAN I GET THIS ==OPERATOR TO WORK IN THIS CASE? </p>

<p>If anyone can really help me resolve this issue quickly, I will seriously praise you with the glory of a thousand suns for saving my ass from not getting an A+ on this project. </p>
