P
Pedro Miguel Carvalho
Greetings.
The following code does not compile and I can't see why! I'm using
C++Builder v6.0 (build 10.160).
<code>
#include <vector>
class test
{
bool Fixed( unsigned int I ) const;
bool& Fixed( unsigned int I );
private:
std::vector<bool> pFixed;
};
bool test::Fixed( unsigned int I ) const
{
return pFixed;
}
bool& test::Fixed( unsigned int I )
{
return pFixed; // error: [C++ Error] test.cpp(21): E2357 Reference
initialized with 'bool', needs lvalue of type 'bool'
}
</code>
If the bool's are replace with int,float,double,a struct, a class, a enum it
compiles and works correctly.
The following code <code> pFixed = true; </code> also works so
"pFixed" is a lvalue.
Is seems to be a compiler error but how can this error go unnoticed?
Thanks,
Pedro Carvalho
The following code does not compile and I can't see why! I'm using
C++Builder v6.0 (build 10.160).
<code>
#include <vector>
class test
{
bool Fixed( unsigned int I ) const;
bool& Fixed( unsigned int I );
private:
std::vector<bool> pFixed;
};
bool test::Fixed( unsigned int I ) const
{
return pFixed;
}
bool& test::Fixed( unsigned int I )
{
return pFixed; // error: [C++ Error] test.cpp(21): E2357 Reference
initialized with 'bool', needs lvalue of type 'bool'
}
</code>
If the bool's are replace with int,float,double,a struct, a class, a enum it
compiles and works correctly.
The following code <code> pFixed = true; </code> also works so
"pFixed" is a lvalue.
Is seems to be a compiler error but how can this error go unnoticed?
Thanks,
Pedro Carvalho