-2

I have a class named Player but when building a constructor like the one below, I got a warning that read: ISO C++ forbids converting a string constant to 'char'. Can anyone tell me what this means and how I can fix it?

class Player
{
public:
    Player(char * firstN = "", char * lastN = "");
};
Hexx
  • 19
  • 2
  • 5

1 Answers1

0

ISO C++ forbids converting a string constant to 'char'

I doubt the compiler said that. It probably said "ISO C++ forbids conversion from string constant to char*" instead. There is a difference.

Can anyone tell me what this means

It means that you're trying to initialise a pointer to char using a string constant. As the error message explains, this is something that cannot be done because a string constant is not implicitly convertible to such type.

how I can fix it?

You can change the argument type to be const char*. A string constant implicitly converts to that type.

eerorika
  • 232,697
  • 12
  • 197
  • 326