cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Constant pointer life time
Constant pointer life time
Mar 17, 2014 at 7:06am UTC
enemy
(470)
hello!
please if we have a constant pointer like:
[code]
int a=1;
int b=2;
int c=3;
int* const pa=&a;
/*pa=&b or
pa=&c; are ERRORS cause pa is only READ ONLY!*/
[/codeg
my question is: how long is pa "blocked " like this- in the scope (block) I suppose!!!
Many thanks!!!
Mar 17, 2014 at 7:28am UTC
TwilightSpectre
(1392)
As long as it exists. Of course, there are ways to 'deconstify' the value, such as
const_cast
, but these should be avoided (otherwise whats the point of it being 'const' anyway?).
Mar 17, 2014 at 5:31pm UTC
enemy
(470)
THANKS!!!
Topic archived. No new replies allowed.