0

vector <point> polygon;
this is my prototype for a class called polygon:
polyg & operator=(polyg& pg);//5

here is the directions:

make An overloaded operator = with a reference parameter of type polyg and a return type of reference polyg.
First make sure its not the same object because if it is then nothing to do. If a different object then
clear the polygon and add the points of the passed polygon to it.

polyg & polyg::operator=(polyg& pg);//5
{
               polyg pgtemp;
        if(pgtemp.polygon[i] == pg.polygon[i])
        {
            break;
        }

            for (int i=0,i<polygon.size(),i++)
            {
                pg.ploygon.erase(i);
                pg.polygon.push_back(polygon.pg[i]);
            }

}

does that work? also i keep gettin a compile error saying:
binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
polyg &polyg::operator =(polyg &)' : member function redeclaration not allowed
'{' : missing function header old-style formal list?)

Edited by happygeek: fixed formatting

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by Narue
0

>does that work?
>also i keep gettin a compile error
Hmm, if you get an error then it probably doesn't work.

>polyg & polyg::operator=(polyg& pg);//5
Remove the semicolon.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.