Hello everyone,
Statement like this,
extern int i = 3;
1. Is it correct?
2. Is it definition or declaration? Any special function or benefits we could get compared with
extern int i; or
int i = 3
thanks in advance,
George
This is a discussion on extern variable assignment within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, Statement like this, extern int i = 3; 1. Is it correct? 2. Is it definition or declaration? ...
Hello everyone,
Statement like this,
extern int i = 3;
1. Is it correct?
2. Is it definition or declaration? Any special function or benefits we could get compared with
extern int i; or
int i = 3
thanks in advance,
George
1) No.
And I thought I had made it quite clear in my other post that it was an example of what could happen if such code was legal.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
This was discussed yesterday - or was it the day before - and no, you should not be allowed to do that.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
A definition does not have an extern keyword.
Using the extern keyword, it can only be a declaration and thus it cannot be initialized.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^