If you add
night
(i.e.
this->
) with
input
then ther is a type mismatch, because the former is a
int
while the latter is a
myint
.
That said, I would rewrite it this way
#include <iostream>
using namespace std;
struct myint
{
private:
int night;
public:
myint(int good) : night(good) {}
myint operator+ (const myint& input)
{
myint result(night + input.night * 2);
return result;
}
int get() { return night;}
};
int main()
{
myint hello(2);
myint good(3);
myint result = hello + good;
cout << result.get() << endl;
}