I'm trying to instantiate an object of an inherited class "Chimp" from the parent class "Animal". The Animal class has a constructor that allows for an int legcount, string skintype, string talk, and a string eats. I have several objects instantiated as:
I am trying to instantiate my Chimp as an Animal though and have something like:
But that is wrong. It returns an error saying it can't implicitly convert Animal to Chimp. When I set it as:
The instantiation works but my Chimp.Unique() Method doesn't work (a method within the chimp class unique to the chimp class).
Can someone please explain if both of those are wrong or how I do it using one or the other but can still reference the unique methods in the class?
Thanks in advance.
Code:
Squirrel squeeky = new Squirrel(FOUR_LEGS, "String1", "String2", "String3"); Chicken cluck = new Chicken(TWO_LEGS, "String1", "String2", "String3");
Code:
Chimp bubbles = new Animal(FOUR_LEGS, "String1", "String2", "String3");
Code:
Animal bubbles = new Chimp(FOUR_LEGS, "String1", "String2", "String3");
Can someone please explain if both of those are wrong or how I do it using one or the other but can still reference the unique methods in the class?
Thanks in advance.
Comment