i'm trying the below basic program, where i'm getting a warning on compailing.
#include<iostream>
#include<cstring>
using namespace std;
class employee
{
private:
char name[20];
int age;
float sal;
public:
void setdata (char *n, int a, float s)
{
strcpy (name, n);
age = a;
sal = s;
}
void showdata()
{
cout << endl << name << '\t' << age << '\t' << sal << endl;
}
};
int main ()
{
employee e1;
e1.setdata("ajay", 23, 4500.50);
e1.showdata();
return 0;
}
But, as soon as i compile this i get the below error;
deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Please explain why am i getting this error, and also the resolution to eliminate. and how dose the resolution works..
Thanks in advance.