if we pass argument by value in assignment operator,
still it dont work.
Assignment operator
yes the inbuilt assignment operator is working correcty but how can we make it. Suppose class contain pointers , then we have to create the assignment operator. How can we create a assignment operator which takes argument by value
if u are making a copying constructor explicitly then u have to pass by reference
because think what u are doing
in upper u are making the copying cons and in main u are using it so when main function is called copy constructor is not made so u cant copy the object u have to pass them by reference
then that means that the function a1 should take an argument by reference and also return that argument by referance
Here i have made copy cons and assignment operator by reference but i made operator+ return by value.
Here variable c takes value from the function operator+ using assignment operator that takes reference.
How is tthis possible?
bhavya in the + operator overloadind function the value will be return in above i have not said it will not return i am saying about the way of passing also in + opeartor u have passed by refernce u can also pass it by value as the copy constrctor is being build and the asiig. operator is overloaded
Hey Bhavya,
I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.