class a
{
int r;
public:
virtual void add()
{
cout<<"in A";
}
};
class b: public a
{
public:
void add()
{
cout<<"in b";
}
};
int main()
{
b d;
d.add();
a f;
f.add();
return 0;
}
// in this code which type of binding is this static of dynamic ?
As you call the methods directly, you're using static binding only.
OO Programming is done using pointers (or references) to objects on virtual members. Repeat myself, add is a virtual function, but as you call them directly, no dynamic binding applies.