Re: I have a pointer, need to call method that takes a const
Well, that's exactly what the original code does, right? OP's
problem was at runtime, not comiple time.
To OP: What do you mean when you say it fails? Does it
crash? If so, what's the call stack?
Note this is MFC so you may want to also ask in the MFC group:
microsoft.public.vc.mfc (though I suspect all the MFC folks visit
here as well)
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================
"Ulrich Eckhardt" <eckhardt@satorlaser.com> wrote in message
news:vepb55-odm.ln1@satorlaser.homedns.org...
bpelot@hotmail.com wrote:
[ Note here: if you quote me, please pay me some respect by doing it
properly. Here you are quoting Ben Voigt, and I think he deserves the same
treatment. ]
What's the prototype for Copy()? Is it a reference parameter? You are
dereferencing the pArray pointer in the call and I wouldn't have
expected
that was necessary.
That was my thought too (makes me feel a little better).
I don't understand why you are passing around pointers at all when the
pointer can't be NULL anyway. That is what C++ uses references for.
The prototype
is: void Copy( const CDWordArray& src );
If I try it as suggested:
OrigArray.Copy (pArray);
I get a compiler error:
error C2664: 'Copy' : cannot convert parameter 1 from
'class CDWordArray *' to
'const class CDWordArray &'
I hope this should be clear now, using the formatting above. You actually
have to dereference a pointer to get a reference. The additional 'const'
is
then added implicitly.
Uli