These are the errors that i am getting

J:Project 2Binary.cpp: In constructor `binary::binary()':
J:Project 2Binary.cpp:37: error: no match for 'operator=' in '((binary*)this)->binary::head_ptr = 0'
J:Project 2Binary.cpp:6: note: candidates are: nodeType& nodeType::operator=(const nodeType&)

J:Project 2Binary.cpp: In copy constructor binary::binary(const binary&)': J:Project 2Binary.cpp:43: error: invalid initialization of reference of type 'nodeType*&' from expression of type 'const nodeType' J:Project 2Binary.cpp:30: error: in passing argument 1 ofvoid list_copy(nodeType&, nodeType&, nodeType&)'
J:Project 2Binary.cpp: In destructor binary::~binary()': J:Project 2Binary.cpp:48: error: invalid initialization of reference of type 'nodeType*&' from expression of type 'nodeType' J:Project 2Binary.cpp:28: error: in passing argument 1 ofvoid list_clear(nodeType
&)'

J:Project 2Binary.cpp: In function `std::istream& operator>>(std::istream&, const binary&)':

J:Project 2Binary.cpp:97: error: invalid initialization of reference of type 'nodeType&' from expression of type 'const nodeType'
J:Project 2Binary.cpp:60: error: in passing argument 1 of void list_clear(nodeType*&)' J:Project 2Binary.cpp:98: error: no match for 'operator=' in 'inclass->binary::head_ptr = 0' J:Project 2Binary.cpp:6: note: candidates are: nodeType& nodeType::operator=(const nodeType&) J:Project 2Binary.cpp:110: error: no match for 'operator==' in 'inclass->binary::head_ptr == 0' J:Project 2Binary.cpp:112: error: no match for 'operator=' in 'inclass->binary::head_ptr = newNode' J:Project 2Binary.cpp:6: note: candidates are: nodeType& nodeType::operator=(const nodeType&) J:Project 2Binary.cpp: In functionstd::ostream& operator<<(std::ostream&, const binary&)':
J:Project 2Binary.cpp:128: error: cannot convert const nodeType' tonodeType
' in assignment

#include <iostream>
#include<cstdlib>
using namespace std;

struct nodeType
{
       int info;
       nodeType *link;
};

class binary
{
      friend ostream& operator<<(ostream& outfile,const binary& outclass);
      friend istream& operator>>(istream& infile, const binary& inclass);
      friend binary& operator+(const binary& num1,const binary& num2);

      public:
             binary();
           binary(const binary & inclass);
             ~binary();
             const binary & operator =(const binary & otherlist);
             int getcount() const;
      private:
              nodeType head_ptr;
              int count;
};

void list_clear(nodeType*&head_ptr);
void list_copy(nodeType*&source_ptr,
     nodeType*&head_ptr, nodeType*&tail_ptr);
void resetlist(nodeType * &mylist);  


binary::binary()
{
                count = 0;
                head_ptr = NULL;
}

binary::binary(const binary & inclass)
{
    nodeType *tail_ptr;
    list_copy(inclass.head_ptr,head_ptr,tail_ptr);
}

binary::~binary()
{
     list_clear(head_ptr);
}
const binary & binary::operator =(const binary & otherlist)
{

}
int binary::getcount() const
{
    return count;
} 

void list_clear(nodeType*&head_ptr)
{
    nodeType *temp;
    while(head_ptr != NULL)
    {
        temp = head_ptr;
        head_ptr = head_ptr->link;
        delete temp;
    } 
}
void list_copy(nodeType*&source_ptr, nodeType*&head_ptr, nodeType*&tail_ptr)
{

}
void resetlist(nodeType * &mylist)
{
    nodeType * templist;

    nodeType * tempnode;

    templist = NULL;
    while(mylist != NULL)
    {
                 tempnode = mylist;

                 mylist = mylist->link;
                 tempnode->link = templist;
                 templist = tempnode;
    }
                 mylist = templist;
}

istream& operator>>(istream& infile, const binary& inclass)
{
    nodeType *newNode, *temp;
    int numconv;
    char ch;

    list_clear(inclass.head_ptr);
    inclass.head_ptr = NULL;

    infile>>ws;
    infile.get(ch);
    temp = NULL;

    while(infile && isdigit(ch))
    {
        numconv = ch -'0';//Converts the number to ASCII
        newNode= new nodeType;
        newNode->info = numconv;
        newNode->link = NULL;
        if(inclass.head_ptr == NULL)
        {
            inclass.head_ptr = newNode;
        }
        else
        {
            temp->link = newNode;
        }
        temp = newNode;
        infile.get(ch);
    }
     infile>>numconv;
}
ostream& operator<<(ostream& outfile,const binary& outclass)
{
    nodeType *newNode;

    newNode = new nodeType;
    newNode = outclass.head_ptr;
    while(newNode != NULL)
    {
        outfile<<newNode->info<< " ";
        newNode=newNode->link;
    }

    return outfile;

}
binary& operator+(const binary& num1,const binary& num2)
{

}

Edited 3 Years Ago by deceptikon: Changed to a discussion thread. Please don&#39;t post code snippets when you&#39;re looking for help

thanks. that helped with most of them.

Edited 3 Years Ago by CHOCHOCHO

Here what's left:

J:\Project 2\Binary.cpp: In copy constructor binary::binary(const binary&)': J:\Project 2\Binary.cpp:43: error: invalid initialization of reference of type 'nodeType*&' from expression of type 'const nodeType'
J:\Project 2\Binary.cpp:30: error: in passing argument 1 ofvoid list_copy(nodeType&, nodeType&, nodeType&)'
J:\Project 2\Binary.cpp: In function std::istream& operator>>(std::istream&, const binary&)': J:\Project 2\Binary.cpp:97: error: invalid initialization of reference of type 'nodeType&' from expression of type 'const nodeType' J:\Project 2\Binary.cpp:60: error: in passing argument 1 of void list_clear(nodeType*&)' J:\Project 2\Binary.cpp:98: error: assignment of data-memberbinary::head_ptr' in read-only structure
J:\Project 2\Binary.cpp:112: error: assignment of data-member `binary::head_ptr' in read-only structure

`

This question has already been answered. Start a new discussion instead.