Dynamic binding

i am a new learner to c++ so i am learning dynamic binding and i did a small program
#include<iostream>
using namespace std;
class Employee;
class Employee
{
public:
int age,len;
char *name;
int salary;

Employee()
{
age=0;
name=NULL;
salary=0;
}
Employee(int a,char *n,int s)
{
age=a;
len=strlen(n);
name=new char[len+1];
strcpy(name,n);
salary=s;
}
Employee(Employee &s)
{
age=s.age;
salary=s.salary;
}

};
int set(Employee &s)
{
cout<<"Enter the name\n";
cin>>s.name;
cout<<"Enter the age \n";
cin>>s.age;
cout<<"Enter the Salary\n";
cin>>s.salary;
return 0;
}
int display(Employee &s)
{
cout<<s.name<<s.age<<s.salary;
return 0;
}

int main()
{
Employee ob1;
int (*f)();
int c;
cin>>c;
if(c==1)
{
f=set(ob1);
}
else
f=display(ob1);


} and i cant figure out where i went wrong
There is no dynamic binding in your code.

You make a lot of mistakes with pointers, so it would be best for you to avoid them.
In your Employee class, use a std::string for name and remove the "len" attribute.

In your main(), f is declared as a function pointer but never used as such. You should remove it completely.
Topic archived. No new replies allowed.