Why are opCall's not implicitely assignable?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Sep 17 15:53:48 PDT 2006


"Karen Lanrap" <karen at digitaldaemon.com> wrote in message 
news:Xns98428255B9E6digitaldaemoncom at 63.105.9.61...
> class C{
>    int opCall(int i){
>      return 2*i;
>    }
> }
>
> int main(){
>    auto c= new C;
>    int x=c.opCall=3; // compiles
>    int x=c=3; // does not compile
> }

Long story short, the compiler sees "c = 3" first as an assignment, and 
since assignment can't be overloaded, it complains. 





More information about the Digitalmars-d-learn mailing list