Re: Strange error! Compiler problem? Or code problem?!!!!!!!

From: Pedro Miguel Carvalho (*SPAM*BLOCK**Pedro_MCLX_at_sapo.pt)
Date: 10/25/04


Date: Mon, 25 Oct 2004 15:06:18 +0100

Ignore it!
I'm having a strange day, no special cases allowed :-).

Pedro Carvalho

"Pedro Miguel Carvalho" <*SPAM*BLOCK**Pedro_MCLX@sapo.pt> wrote in message
news:417cf195$0$12624$a729d347@news.telepac.pt...
| 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[I];
| }
|
| bool& test::Fixed( unsigned int I )
| {
| return pFixed[I]; // 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[I] = true; </code> also works so
| "pFixed[I]" is a lvalue.
|
| Is seems to be a compiler error but how can this error go unnoticed?
|
| Thanks,
| Pedro Carvalho



Relevant Pages

  • Strange error! Compiler problem? Or code problem?!!!!!!!
    ... The following code does not compile and I can't see why! ... bool& Fixed(unsigned int I); ...
    (comp.lang.cpp)
  • take your advantage improved ATL::CComBSTR class
    ... For the guys that want neat COM interop and not convert the CString or std: string classes to a BSTR constantly, this class is an ideal candidate. ... unsigned int ByteLength() const throw ... HRESULT CopyTothrow ... HRESULT Replace(BSTR find, BSTR replace, bool caseInsensitive) throw ...
    (microsoft.public.vc.atl)
  • Re: Dont want Intermediate language
    ... Express will certainly compile it. ... BOOL CALLBACK WndProc; ... void ShowError; ... bool create_sfx(const char* file, const char *toFile) ...
    (microsoft.public.vc.language)
  • Re: 32-bit adder in c/c++
    ... > comparison instructions. ... unsigned int result:1; ... > bool AND; ... Read the FAQ about bit manipulation and signed vs. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [PATCH] Staging: vt6656: Remove PUINT from ttype.h
    ... BOOL BSSbIsSTAInNodeDB(void *hDeviceContext, ... +void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex) ... PUINT pcbHeaderSize, ...
    (Linux-Kernel)