Hello, I have a pump class that requires the use of a member variable, which is a pointer to a wchar_t array containing the port address, that is: "com9".
The problem is that when I initialize this variable in the constructor, my compiler displays a warning with a deprecated conversion.
pump::pump(){ this->portNumber = L"com9";}
This works fine, but the warning every time I compile is anonymous and makes me feel like I'm doing something wrong.
I tried to create an array and then set a member variable as follows:
pump::pump(){ wchar_t port[] = L"com9"; this->portNumber = port;}
But for some reason this makes my portNumber a point in 'F'.
Clearly, another conceptual problem on my part.
Thanks for the help in questions related to noobish.
EDIT:
As a request, the definition of portNumber was:
class pump { private: wchar_t* portNumber; }
Thanks to the answers, it is now changed to:
class pump { private: const wchar_t* portNumber; }
source share