Search Result

Collapse
2 results in 0.0015 seconds.
Keywords
Members
Tags
derived
  •  

  • sandromani
    started a topic Derived class mystery
    in Java

    Derived class mystery

    Okay so here is a tricky example from my lecture notes:
    Code:
    class Base {
        private int val;
        Base () {
    	val = lookup();
        }
        public int lookup() { 
    	return 5; 
        }
        public int value() {
    	return val;
        }
    }
    class Derived extends Base {
        private int num=10;
        public int lookup() {
    	return num;
        }
    }
    class Test
    ...
    See more | Go to post

  • Call functions of derived classes in a list of base class

    So, I have created some Collision Detection classes that all derive from a base class known as CollisionBase.

    I have a List<CollisionB ase> in which I will be going through and calling a method known as Intersect. CollisionBase and all of the derived classes have this method defined, with the CollisionBase class having it as virtual and the defined classes having it as override.

    This list will contain up to three...
    See more | Go to post
Working...