Re: objects as parameters

From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 05/14/04


Date: Fri, 14 May 2004 09:53:57 +0100

In message <wKSdnRfxvr1Tsjnd4p2dnA@comcast.com>, Anthony C
<AntMJ2317@comcast.net> writes
>i have tried making a reference copy of the cat,im not getting
>anywhere, this is what ive tried...this is just a snippet
>
>void test(cat& catOne)
>{
> cout << catOne.getAge() << endl;
>}
>
>int main()
>{
> cat Frisky;
>
> Frisky.setAge(5);
>
> test(Frisky);
> return 0;
>}
>
>the reference parameter is there, ive passed it in, unless im doing
>something very wrong, that 'should' work, should it not?

Indeed it should, so if it isn't you will need to look elsewhere for the
problem. When you say does not work, do you mean does not compile, does
not link or does not execute as expected?

>
>unless your talking pointers and using the -> operator?

No, forget pointers (don't use them unless they are actually necessary)

-- 
Francis Glassborow      ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


Relevant Pages

  • Re: passing const ptr argument
    ... > I want to write protect an argument that is passed by reference. ... > Anthony Lansbergen ... Note the const at the end of the function decl. ...
    (comp.lang.cpp)
  • Re: Different between operator comparision and .Equals(x)
    ... Anthony wrote: ... The '==' operator for reference types is by default a reference ... Only if the two values refer to the same object does it ... The Equals method is virtual, and thus is selected by dynamic dispatch ...
    (microsoft.public.dotnet.framework)
  • Re: TEM spot sizes
    ... Lasers, by Anthony E. Siegman, is a good reference. ...
    (sci.optics)
  • Re: Real World Flunks (Re: Why is Object Oriented so successful)
    ... AndyW wrote: ... "modeling the real world". ... CADD screen closely matches the object pointers in a typical real- ... I think the fact one has a reference to it ...
    (comp.object)
  • Re: The Java no pointer big fat lie!
    ... > reference types, it wouldn't be a good comparison. ... and what you can't - and there is a big difference in Java to C and C++. ... You cannot change it in the language itself, ... Thus I would distinguish pointers from ...
    (comp.lang.java.programmer)