0

hey guys,
I`m trying to overload operator = in my class in windows application`s form , I`m not sure what is my problem,would you take a look at my code?

public struct Customer
{
    // Public members
   // public string Name;
    public string Name;
    public string ID;
    public string Address;
    public string Hour;
   

   public  Customer operator +(Customer ob)
    {
        this.Name = ob.Name;
        this.ID = ob.ID;
        this.Address = ob.Address;
        this.Hour = ob.Hour;
return *this;
    }
}
3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Rashakil Fol
0

Weuw heavy! I am afraid you cannot overload the = operator.
Think about it. Would it make any sence to do that?
You can overload the + operator for Customer. But then again what would be the meaning of Customer A + Customer B.
If you want to assign A to B, just use A=B.

0

hey guys,
I`m trying to overload operator = in my class in windows application`s form , I`m not sure what is my problem,would you take a look at my code?

Your problem is really just that you're trying to write C++ instead of C#.

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.