Skip to content

Files

Latest commit

 

History

History

53

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Exercise 6.53

Explain the effect of the second declaration in each one of the following sets of declarations. Indicate which, if any, are illegal.

(a)

int calc(int&, int&);
int calc(const int&, const int&);

(b)

int calc(char*, char*);
int calc(const char*, const char*);

(c)

int calc(char*, char*);
int calc(char* const, char* const);

Solution

(a)'s second declaration will declare a second function which accepts references to const ints. (b)'s second declaration will similarly declare a second function which accepts pointers to const chars. (c) is illegal, because it declares two functions which accept pointers to chars, which can both accept const pointers.