assignment operator overloading in c++

前端 未结 6 1929
醉梦人生
醉梦人生 2021-02-01 15:07

I have used the following code for assignment operator overloading:

SimpleCircle SimpleCircle::operator=(const SimpleCircle & rhs)
{
     if(this == &rhs         


        
6条回答
  •  离开以前
    2021-02-01 15:22

    #include
    
    using namespace std;
    
    class employee
    {
        int idnum;
        double salary;
        public:
            employee(){}
    
            employee(int a,int b)
            {
                idnum=a;
                salary=b;
            }
    
            void dis()
            {
                cout<<"1st emp:"<>a>>b;
        employee e1(a,b);
        e1.dis();
        employee e2;
        e2=e1;
        e2.show();  
    }
    

提交回复
热议问题