-4
class str
{
    char *p;
    public:
       string(const char *s);
}

I am confused about the difference between these two declarations.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574

1 Answers1

1

const char * is a pointer to a const char, you cant change the value being pointed to, but you can change the pointer

char * const is a constant pointer to a char, [behaving like a reference type] you can change the value pointed to but you cant change the pointer.

const char * const is a constant pointer to a constant char, [both are constants]

ppavlov
  • 378
  • 5
  • 14