I truly don't understand why this works like this.
#include<iostream>
using namespace std;
class Figura{
public:
int x;
int y;
virtual void pomak(int dx=10,int dy=1)
{
x+=dx;
y+=dy;
cout<<"Figura"<<endl;
}
};
class Skakac:public Figura{
public:
void pomak(int dx=2,int dy=-1)
{
cout<<dx<<endl;
x+=dx;
y+=dy;
cout<<"Skakac"<<endl;
}
};
int main()
{
Skakac S;
S.x=0;
S.y=0;
Figura* x=&S;
cout<<x->x<<" "<<x->y<<endl;
x->pomak();
cout<<S.x<<" "<<S.y<<endl;
}
When i call function pomak() it couts dx as 10, although it calls second function pomak(not the virtual one) and i clearly stated that dx = 2.