[C/C++] Why I can't assign a constant char pointer to a char pointer?
Hey Community, just started learning C++ 2 days ago, but already have much experience with ANSI-C. Although I donât learning programming with this plattform, I use it to ask some questions ;) My problem now is the following, let me show this shortened code snipped: class Entity{ private: char* name; public: Entity(const char* name1){ name = name1; } } int main(){ Entity person("Steve"); } But this doesnât work, because I canât assign "Steve" which is a (constant) chain of chars to Entity::name which holds a pointer of a char. So I must declare Entity::name as a constant or assign it with a defined range. But that donât make sense for me. I mean, the string "Steve" is lying somewhere in the memory, so I should pointing to it. But no. Sorry if this is a bit unclear, german is my mother tongue.