The below written very basic code is giving me a warning and this program is not running - “warning: ISO C++ forbids converting a string constant to char*”.
Why there this error is? and what is the solution?
#include
#include
using namespace std;
class car{
public:
int model_no;
int price;
char name[20];
car(int m, int p, char *n){
model_no = m;
price = p;
strcpy(name, n);
}
void print(){
cout<<model_no<<endl;
cout<<price<< endl;
cout<<name<<endl;
}
};
int main(){
car c(100,200,"Ferrari");
c.print();
return 0;
}