jeudi 20 décembre 2018

Why can't I use 'const (char*) cstr = 0;' to define a const char pointer in C++?

I know the following code could do it:

typedef char *pstring;
const pstring cstr = 0;

But when I used 'const (char*) cstr = 0;', I got a compiler error;

cpp_2.cc:75:5: error: expected primary-expression before ‘const’
const (char*) cstr1 = 0;

So, why can't we use parentheses to do the similar job as typedef?

Aucun commentaire:

Enregistrer un commentaire