V
Viraj Mody
I was just visiting some old C++ book and started thinking about something
I had seen 2 years ago - what is the maximum number of consts you can
legally use in a C++ line of code?
I came up with 5:
const int* const myClass::myFoo(const int* const arg) const {
....
}
Anyone can think of something with more 'consts' in it?
Also, while on the subject of const, wanted to verify if I have this
right:
const int* cp = &a;
--> this means that I cannot reassign cp to point to anything else.
int* const pc = &a;
--> this means that pc can point only to the address of 'const
int' variables. So I could go ahead and say:
pc = &b;
as long as b is of type 'const int'.
I have a feeling that I might have mixed up the two - please correct me if
I have.
Thanks.
-Viraj
I had seen 2 years ago - what is the maximum number of consts you can
legally use in a C++ line of code?
I came up with 5:
const int* const myClass::myFoo(const int* const arg) const {
....
}
Anyone can think of something with more 'consts' in it?
Also, while on the subject of const, wanted to verify if I have this
right:
const int* cp = &a;
--> this means that I cannot reassign cp to point to anything else.
int* const pc = &a;
--> this means that pc can point only to the address of 'const
int' variables. So I could go ahead and say:
pc = &b;
as long as b is of type 'const int'.
I have a feeling that I might have mixed up the two - please correct me if
I have.
Thanks.
-Viraj