Conversion from const char* to char*

Feb 6, 2019 at 10:12pm
Is it possible to make such conversion because in our university we are asked to use char * for every attribute that has a name.For example a class Person has char *name,char *surname.Now if i have a constructor for Person like this Person(char * name1,char *surname1) is it possible somehow in make when you make an object Person to do something like this
Person p("Mike","Joe").I know here Mike and Joe are const char,but is there way to manage that problem.Only thing i had remembered is to create for example char* s,and to make a user to write the name into it.

Last edited on Feb 6, 2019 at 10:14pm
Feb 6, 2019 at 10:50pm
I have find solution only to put const char * im my fuctions where i need it.
Feb 7, 2019 at 2:46am
closed account (E0p9LyTq)
const_cast can be your friend.

https://en.cppreference.com/w/cpp/language/const_cast

But it should be used sparingly, better to rewrite your code to not need casting.
Topic archived. No new replies allowed.