char* f() {
cout << b;
return "B::f";
}
Ok so I have this piece of code inside a class and I keep get this error
'return': cannot convert from 'const char [5]' to 'char*'
I tried some online compilers and it works just fine .
So why is this happening ?
The return type of this function indicates that the storage it points to can be changed. However you return a literal, which does not allow modifications.
Change the signature to
and it will work.