Re: objects as parameters

From: Anthony C (AntMJ2317_at_comcast.net)
Date: 05/14/04


Date: Thu, 13 May 2004 23:02:00 -0400

osmium wrote:

> Anthony C 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?
>>
>>unless your talking pointers and using the -> operator?
>
>
> Nothing stands out to me as being wrong. Why not post the class too? No, I
> didn't mean ->. It looks like pass by value should be OK too, based on the
> function names and my guesses as to what you are doing.
>
>
well, passing by value isnt going to accomplish much for me since
private variables are changed throughout the program. passing by
reference would be best for me atm. just need to figure out how to do it



Relevant Pages

  • Re: Whats the difference of those two ways of passing parameters
    ... Parameter passing in C is beautifully simple: ... reference", you just pass a pointer and modify the object through that. ... In languages like Java, ... int foo = 42; ...
    (comp.lang.c)
  • Re: pointer syntax
    ... > really passing a reference (which is like an old-school pointer, ... > a copy of the primitive's value and passing that. ... build them yourself with pointers. ... mean a var parameter, write a var parameter. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Passing by reference
    ... It depends upon the reason one is passing the reference. ... instantiate all relationships via a constructor so there will always be ... I naturally think of 'getter' methods as 'knowledge ...
    (comp.object)
  • RE: Passing arguements by reference
    ... even without using the ref keyword. ... Passing a value type by value ... Passing a value type by reference ... When you pass value types they by default get copied, so passing an int into ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using ref
    ... the address of a variable that contains a reference to an object, ... the C version is passing the address of a variable that contains the   ... Inasmuch as the specification is unambiguous, there is a single truth. ... Every time he states the incorrect view, I will feel compelled to correct his incorrect statements. ...
    (microsoft.public.dotnet.languages.csharp)