0

I have a function prototype inside a public class access specifier. This is the prototype:

friend void operator=(String &s,char *str);

The String is the class where it's prototyped. As you can see it's a friend function. By keeping it this way it gives me this error:

operator =' must be a non-static member // Error: operator= must be a member function

And when I remove the friend property it gives me this error:

error C2804: binary 'operator =' has too many parameters

What's wrong with this prototype? There's no call at operator= function currently, so there shouldn't be any error even without the function definition.

4

1 回答 1

2

如果它是 String 类的一部分,那么它就是对某事物的赋值this,所以它只需要一个参数。

于 2013-07-06T21:26:15.417 回答