On Sun, 20 May 2007 02:43:57 GMT, "Daniel T." <da******@earthlink.net>
wrote:
>In article <f8********************************@4ax.com>,
Lilith <li****@dcccd.eduwrote:
>I have a class called Intersection which contains the following with
public access...
Intersection operator= (Intersection &i);
It's defined as...
Intersection Intersection::operator= (Intersection &i)
{
this->ID = i.ID;
this->x = i.x;
[snip]
this->se = i.se;
this->ss = i.ss;
this->sw = i.sw;
}
If all your op= does is assign each member to its corresponding member,
then remove the op= from your class and everything will work.
I tried that and it still issued the same error. It's as if it thinks
I'm referencing a totally different class.
>BTW, the canonical op= is "Type& operator=( const Type& );" and
sometimes you will see, "Type& operator=( Type );" or even "const Type&
operator=( const Type& );"
>Your signature is rather non-standard.
I realized that later and fixed it. Still the same results though.
>Can anyone see where my error is?
>Your error is that you are not showing the code that fails to compile.
Note that the code below compiles fine.
Did I not? I thought it was stated in the part where I said:
"binary '=' : no operator defined which takes a right-hand operand of
type 'class Intersection' (or there is no acceptable conversion)
with regards to the Landscape[j] = temp statement."
I avoided putting markers on the code itself for fear of obscuring
what was original and what was a marker.
However....
>class Intersection
{
public:
Intersection operator=( Intersection& i );
};
Intersection Intersection::operator=( Intersection& i )
{
return *this;
}
void clearLandscape()
{
Intersection temp;
Intersection landscape[250];
for (int j=0; j < 250; j++) {
landscape[j] = temp;
}
}
Ach! That helped me locate the error. I erroneously declared
Landscape as type IStruct, a structure with similar members to
Intersection which I will be using to set values from a series of
IStruct arrays at various parts of the program. Once it compiled with
Landscape declared local to the function I started looking at the
original declaration of Landscape and discovered my error.
Many thanks for your help.
--
Lilith