I am trying to use a constant typedef returned from a function. I need help in getting a const char * returned from the function. A test case is shown below.
typedef char Char;
typedef Char * CharPtr;
const CharPtr getChar();
const char * p;
p = getChar();
const CharPtr getChar()
Now when I compile this I get " Function cannot return a const qualified type" on both the prototype and the definition.
Now I know that a function can return a pointer to a constant object but not a constant object.
And I did find one description in my "C++ Primer" book stating that the const modifies the type of cstr. So that in this case getChar is returning "char * const" and not a "const char *" as expected.
But I don't know how to modify the typedef in order to get "const char *". Any help appreciated.