I don't get it.. are you checking to see if WE know the answer?
Think it over, there are only so-many possabilities.
And sometimes even checking them all and seeing what works and what doesn't work is a great learning experience.
Anyhow, Good luck, i doubt anyone will answer this..
You need a constructor that takes an int for the first line to compile. You need a copy constructor for the second line (the default one provided by the compiler should be fine).
You need operator+= that takes another instance of the class for the third line to compile.
Now what operator+= is supposed to do, I don't know.
class A
{
public:
...
A & operator=(const A &rhs)
{
//Please write your codу here..
}
...
};
int main()
{
A a1(2);
//THe operator overload above A& operator=(..) is used in this assignment below
A a2 = 3;
a1 += a2;
return 0;
}
Now you need to create a constructor and overload the "+=" operator. As well as implement them all.
class A
{
private:
int t;
public:
A::A (int a) { //Default constructor
t = a;
}
A::A (const A& rv) { //Copy constructor
t=rv.t;
}
A & operator=(const A &rhs)
{
//Please write your codу here.. I don't know
}
A & A::operator+=(const A &rhs) {
//Please write your codу here.. I don't know
return *this;
}
};
int main()
{
A a1(2);
//THe operator overload above A& operator=(..) is used in this assignment below
A a2 = 3;
a1 += a2;
return 0;
}