SuperClass instance points to SubClass Method After Casting Programming Software Development by murali2489 … static void main(String[] args) { SuperClass object1 = new SubClass(); SuperClass object2 = new SuperClass(); SubClass objectx = new SubClass(); SuperClass objecty = (SuperClass)objectx; //SubClass object3 = (SubClass)object2… Re: Function inheritance / superclass vector problem Programming Software Development by mike_2000_17 …0; virtual ~Impl() throw() { }; SuperClass Encapsulate() throw() { return this; }; }; private: Impl* pImpl; SuperClass(SuperClass::Impl* aImpl = NULL) throw() :… someMethod() { pImpl->someMethod(); }; ~SuperClass() throw() { delete pImpl; }; SuperClass(const SuperClass& aObj) throw() : pImpl(aObj.pImpl… Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by JamesCherrill …class cast exception. So, this example works [CODE]Superclass ref=new Sub2(); ((Sub1)ref).display()[/CODE] … objects of type Sub1 and of Superclass. This example fails [CODE]Superclass ref=new Sub1(); ((Sub2)ref).… = (create some valid object inout stream); ref = (Superclass) inbound.readObject();[/CODE] will work, or not work, depending… Function inheritance / superclass vector problem Programming Software Development by bleedi So, here's my problem: I have a superclass: [CODE] Class SuperClass { virtual someMethod() = 0; } [/CODE] ... and then I… have multiple classes that inherit SuperClass. Now, if I want to put objects made from the… subclasses to a single vector<SuperClass>, how could I get the abstract function… Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by java_programmer …() { System.out.println("Super"); } } class Sub1 extends Superclass { void display() { System.out.println("sub class1"); } …} } public class reference { public static void main(String[] args) { Superclass ref=new Sub1(); ref.display(); ((Sub2)ref).display(); } } I am… Re: Function inheritance / superclass vector problem Programming Software Development by Garrett2011 … the vector. For example... [CODE] vector<SuperClass*>::iterator begin = testVector.begin(); vector<SuperClass*>::iterator end = testVector.end(); for… be as it follows: [CODE] vector<SuperClass*>::iterator begin = testVector.begin(); vector<SuperClass*>::iterator end = testVector.end(); for… Re: Function inheritance / superclass vector problem Programming Software Development by bleedi [QUOTE=firstPerson;1297202]Does SuperClass have to be abstract?[/QUOTE] Yeah, for ensuring that all … the vector. For example... [CODE] vector<SuperClass*>::iterator begin = testVector.begin(); vector<SuperClass*>::iterator end = testVector.end(); for… Re: Function inheritance / superclass vector problem Programming Software Development by bleedi … I can implement the needed functions in the SuperClass, thus making the abstract SuperClass obsolete. Still, I'm getting some weird crashes… Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by aditya027 …out.println("Super"); } } class Sub1 extends Superclass { void display() { System.out.println("sub … reference { public static void main(String[] args) { Superclass ref=new Sub1(); ref.display(); ((Sub2)ref).display(); … Re: Function inheritance / superclass vector problem Programming Software Development by mrnutty Does SuperClass have to be abstract? Re: Function inheritance / superclass vector problem Programming Software Development by bleedi …, it crashes on this: [CODE] if(!testVector.empty()) { vector<SuperClass*>::iterator begin = testVector.begin(); cout << "Type… Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by tong1 …with the super class reference. [CODE]class Superclass{ void display(){ System.out.println("Super&…new Sub2(); sub2.display(); } } class Sub1 extends Superclass{ void display(){ System.out.println("sub class1"… reference { public static void main(String[] args){ Superclass ref=new Sub1(); ref.display(); ref.Sub2Display(); //invoke… Re: Function inheritance / superclass vector problem Programming Software Development by Garrett2011 …, it crashes on this: [CODE] if(!testVector.empty()) { vector<SuperClass*>::iterator begin = testVector.begin(); cout << "Type… pushing a value up to superclass Programming Software Development by beatlea … in Java and am straggling with it. I have a superclass LivingThing and two subclasses, Monster and Human. Both subclasses have… of it is different for each of them. In my superclass I wrote a method setStrength(int strength), which checks if… values in subclasses and push this value up to the superclass while creating a new object? Thanks Anna Re: pushing a value up to superclass Programming Software Development by new_2_java … Java and am straggling with it. I have a superclass LivingThing and two subclasses, Monster and Human. Both subclasses… it is different for each of them. In my superclass I wrote a method setStrength(int strength), which checks…values in subclasses and push this value up to the superclass while creating a new object? Thanks Anna[/QUOTE] … Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by mayank.dyl It is not possible to call a method of any sub class from a instance of superclass. Although u can call methods defined in superclass by a instance of sub class. [CODE]sub1 ref=new sub1(); ref.display();[/CODE] How to call polymorphic method of superclass with the object of subclass Programming Software Development by Waseem Siddiqui [B]I want to override a method of superclass in subclass the method have same name in both the …class. But I want to call the method of superclass with the object of subclass Please Hlep[/B] Please consider… the subclass. I want to call the method of the superclass with the object of subclass. Is it possible can any… Re: pushing a value up to superclass Programming Software Development by beatlea … they set maxStrength too late. In my subclass I call superclass constructor and one of its parameters is strength, which then… happens and I cannot call setMaxStrength() from subclass before calling superclass constructor. Hope it makes sense. Anna Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by JamesCherrill … the superclasses are initialised properly. However, when you instantiate the superclass none of the subclass contructors are called, so none of… Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by aditya027 … the superclasses are initialised properly. However, when you instantiate the superclass none of the subclass contructors are called, so none of… Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by aditya027 … my question is i am giving a super class reference(Superclass) to its subclass(Sub1) object and i am trying to… Re: Is it possible to invoke a method of second subclass from its superclass? Programming Software Development by JamesCherrill … variables you do not have access to. Eg: suppose the Superclass defines [I]Date whenInstantiated[/I]; and initialises this to [I… Re: pushing a value up to superclass Programming Software Development by beatlea … which are the same for all subclasses up to their superclass. Could you also advice me on menu class? I have… Cannot find the superclass when creating a package Programming Software Development by KSM899 … make them as a package , it works fine with the superclass but it doesn't with the other classes, It always….YEAR); /** * A constrector that initilaize the Car variables and the superclass "Policy" variables */ public Car (int ccregnumbe, int cyear… Re: delete superclass - affects subclass? Programming Software Development by Narue [B]>superclass (or parent class if you will) >subclass (or child … C++ standard uses "base" for superclass and "derived" for subclass. Superclass and subclass have traditionally been very confusing… SubClass method doesn´t overwrite Superclass method Programming Software Development by HelloMe Oje me again... :$ Hello everyone... I have a superclass Human and a subclass Warrior. Problem is, human got this … doesn´t... i gives me only the output from the superclass method. It shouldn´t be like that. The class with… Re: How to call polymorphic method of superclass with the object of subclass Programming Software Development by JamesCherrill create a new method in the subclass to pass the call on to the superclass, yhe call that instead public void superA1() { super.a1(); } Override a superclass's methods with a subclass Programming Software Development by zach&kody How do you override a superclass's methods with a subclass? These are my two programs, … the subclass of which I am attempting to override the superclass's methods. [CODE]// This class represents a walker with two… Arguments from a Superclass init Programming Software Development by slamshuffle …'m not sure how to call the __init__ of the superclass. Basically what I'd like to have is to be… also the general ones given in the __init__ of the superclass. If I include StockItem.__init__(etc) in the __init__ of… delete superclass - affects subclass? Programming Software Development by Excizted Hi. I have a little question, that which answer may mean death to my class plans. I have a superclass (or parent class if you will) that I have to delete when I'm done with it, but does that affect the subclass (or child class if you will)? Simple question, hope the answer is as simple :D Thanks'es. -Excizted.