Re: Works in Visual C++ 2003 but not in 2005



John wrote:
> Hi,
>
> I am working on a C++ project which has been developed with Visual
> Studio.Net 2003. When I compile it with Visual Studio 2005, it gives
> hundred of errors. Two of the strange errors are following, which
> repeated in many places:
>
> 1-error C2664: 'action' : cannot convert parameter 1 from 'Foo *' to
> 'const Foo *&'

Comeau C++ agrees with VC++ 2005 - the code is ill-formed according to the
C++ standard.

Possible workarounds, depending on what you're doing in "action":

void action(const Foo* const & cptr);

or

void action(Foo * const & cptr);

or

void action(Foo *& cptr);

or

Foo* fPtr = new Foo();
action(const_cast<const Foo*&>(fPtr));

-cd


.



Relevant Pages

  • Re: compile error about auto_ptr
    ... The signature of `vector::push_back' method requires const ... void push_back (const Foo& input) ...
    (microsoft.public.vc.language)
  • Re: is const function faster than non-const?
    ... > void foo() const; ... > void goo(); ... what does compiler optomization does to const function? ...
    (comp.lang.cpp)
  • Re: compile error about auto_ptr
    ... I have tried and it gives the same error message. ... The signature of `vector::push_back' method requires const ... void push_back (const Foo& input) ...
    (microsoft.public.vc.language)
  • Re: Funky function
    ... >> It makes it possible to call this member function on a const object ... >> object may or may not be const). ... int Data; ... in the next line you try to call a function foo on MyData. ...
    (comp.lang.cpp)
  • Re: pass by Reference/value ???
    ... > void foo ... this would be called "passing by reference". ... foo receives a local copy of s and any changes that it makes to s only ... Since s is a pointer, a variable storing the address of s is a pointer to ...
    (comp.lang.cpp)

Loading