T
Tim Clacy
1) Is this initialising the reference 'u' to the address of the literal '2'
or to the address 0x00000002?
unsigned const& u = 2;
2) What is the different between the initialisation of 'u' and 'S::u' below?
unsigned const& u = 2;
struct S
{
unsigned const& u;
S() : u (2) { }
} s;
int main(int argc, char* argv[])
{
return 0;
}
VisualStudio 2005 generates "error C2354: 'S::u' : initialization of
reference member requires a temporary variable" but does not complain about
the initialisation of 'u'. A couple of other compilers that I have say
nothing about either (GCC 3.3.4, ADS 1.2).
Any illumination will be greatly appreciated.
Tim
or to the address 0x00000002?
unsigned const& u = 2;
2) What is the different between the initialisation of 'u' and 'S::u' below?
unsigned const& u = 2;
struct S
{
unsigned const& u;
S() : u (2) { }
} s;
int main(int argc, char* argv[])
{
return 0;
}
VisualStudio 2005 generates "error C2354: 'S::u' : initialization of
reference member requires a temporary variable" but does not complain about
the initialisation of 'u'. A couple of other compilers that I have say
nothing about either (GCC 3.3.4, ADS 1.2).
Any illumination will be greatly appreciated.
Tim