Hello! I was trying to overload unary operatirs ++ and --. You can see the code below. And this is the compiler messege: 12:6: error: expected initializer before 'Base'
Any advice on how to fix this would be welcome. Thank you in advance!
// overloading operators
#include <iostream>
usingnamespace std;
class Base {
public:
int x, y, z;
Base() {x = y = z = 0; }
Base(int c, int d, int f) {x = c; y = d; z = f; }
Base operator++();
Base operator--();
}
Base Base::operator++()
{
x++;
y++;
z++;
return *this;
}
Base Base::operator--()
{
x--;
y--;
z--;
return *this;
}
int main () {
Base data(1,2,3);
++data;
cout<<data.x<<","<<data.y<<","<<data.z<<endl;
--data;
cout<<data.x<<","<<data.y<<","<<data.z<<endl;
return 0;
}