what's wrong with the polymorphism here?
class A
{
public:
int x;
virtual void dosomething(const A& ob) = 0;
};
class B : public A
{
public:
int y;
void dosomething(const A& ob) { // I assume this will work (base class accepting a derived class by reference)
x += ob.x;
y += ob.y; // error: const class A has no memeber named 'y'
cout<<x<<" "<<y;
}
};
int main()
{
B s, m;
s.x = 3;
s.y = 9;
m.x = 3;
m.y = 9;
s.dosomething(m);
}
i tried using pointer instead of reference, and still not working
should i override the function?