Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualNypyren

Posted 16 August 2013 - 10:32 PM

You have to build a new type to do the same thing explicitly:
 
class RefToCow
{
  public cow cow;
}

...

static void Main()
{
  RefToCow RefCow;
  cow Cow1 = new cow(5);
  cow Cow2 = new cow(10);
  RefToCow RefToRefCow;

  RefCow.cow = Cow1;
  RefToRefCow = RefCow;
  ReftoRefCow.cow.HowMuchWeight();

  RefCow.cow = Cow2;
  ReftoRefCow.cow.HowMuchWeight(); // Prints 10 now.
}
This has the same behavior as doing pointer-to-pointer in C and C++. You just have to spell it all out using a member variable.

#4Nypyren

Posted 16 August 2013 - 10:25 PM

You have to build a new type to do the same thing explicitly:
 
class RefToCow
{
  public cow cow;
}

...

static void Main()
{
  RefToCow RefCow;
  cow Cow1 = new cow(5);
  cow Cow2 = new cow(10);
  RefToCow RefToRefCow;

  RefCow.cow = Cow1;
  RefToRefCow = RefCow;
  ReftoRefCow.HowMuchWeight();

  RefCow.cow = Cow2;
  ReftoRefCow.HowMuchWeight(); // Prints 10 now.
}
This has the same behavior as doing pointer-to-pointer in C and C++. You just have to spell it all out using a member variable.

#3Nypyren

Posted 16 August 2013 - 10:24 PM

You have to build a new type to do the same thing explicitly:
 
class RefToCow
{
public cow cow;
}

...

static void Main()
{
RefToCow RefCow;
cow Cow1 = new cow(5);
cow Cow2 = new cow(10);
RefToCow RefToRefCow;

RefCow.cow = Cow1;
RefToRefCow = RefCow;
ReftoRefCow.HowMuchWeight();

RefCow.cow = Cow2;
ReftoRefCow.HowMuchWeight(); // Prints 10 now.
}
This has the same behavior as doing pointer-to-pointer in C and C++. You just have to spell it all out using a member variable.

#2Nypyren

Posted 16 August 2013 - 10:23 PM

You have to build a new type to do the same thing explicitly:

class RefToCow
{
public cow cow;
}

...

static void Main()
{
RefToCow RefCow;
cow Cow1 = new cow(5);
cow Cow2 = new cow(10);
RefToCow RefToRefCow;

RefCow.cow = Cow1;
RefToRefCow = RefCow;
ReftoRefCow.HowMuchWeight();

RefCow.cow = Cow2;
ReftoRefCow.HowMuchWeight(); // Prints 10 now.
}

#1Nypyren

Posted 16 August 2013 - 10:23 PM

You have to build a new type to do the same thing explicitly:

[code=auto:0]
class RefToCow
{
public cow cow;
}

...

static void Main()
{
RefToCow RefCow;
cow Cow1 = new cow(5);
cow Cow2 = new cow(10);
RefToCow RefToRefCow;

RefCow.cow = Cow1;
RefToRefCow = RefCow;
ReftoRefCow.HowMuchWeight();

RefCow.cow = Cow2;
ReftoRefCow.HowMuchWeight(); // Prints 10 now.
}

PARTNERS