How to reassign a variable's class

Hi, I’ve got an instance where I need to change the class of a variable so that it could be one of two classes. How would I do this?

var aVar;
var aNum:int;

if(aNumb == 1)
{
  // aVar gets class 'fish'
}
else if(aNumb == 2)
{
  // aVar gets class 'bird'
}

Make a common superclass, like ‘animal’ and derive ‘fish’ and ‘bird’ from ‘animal’ Then if the var is of type ‘animal’ it should accept ‘fish’ or ‘bird’

untested:

class Animal ( can add 'extends MonoBehaviour' here if it would be such a thing)
{
  var legs : int; // for example
}

class Bird implements Animal
{
 Bird() { legs = 2; } // constructor to initialize whatever
}

class Fish implements Animal
{
 Fish() { legs = 0; }
}

var f : Fish = new Fish();
var b : Bird = new Bird();
var a : Animal;
a = f;
a = b;