Is there a way to require a subclass to call super explicitly in it's constructor?

Member Avatar
Member Avatar
+0 forum 4

I'm trying to create a list stack that implements some interface called SomeList The list stack should only use stack with no links. the itnerface has a number of methods that I would like to implement. So for SomeList I have something like public interface SomeList<T>{public void plus(T something);public E takeout(int somewhere); and so on} For the generic ListStack I have something like public class ListStack<T> implements SomeList<T>{ Stack<T> stack1=new Stack<E>(); //constructor public LinkStack(){ stack1=new Stack<T>(); } //method public void plus(T somethig){ this.push();} . . . } In the method above (plus(T something)) I get an error on push. Eclipse …

Member Avatar
Member Avatar
+0 forum 13

In java this is how a DerivedClass can implement it's BaseClass's constructor. public DerivedClass extends BaseClass { //some properties public DerivedClass(param) { super(param); } } I have learnt C-Sharp's *base()* does the similar thing, but when I replace *super(param)* with *base(param)*, it does not gives what I'm expecting. How can I implement this code snippet in C#?

Member Avatar
Member Avatar
+0 forum 3

<? super Animal> means animal or it's superclass only. Then why inside the method it's allowing to add Dog object even though it's a subclass of Animal? This program compiles and runs! import java.util.*; class Cat {} class Animal{Animal() {System.out.println("Animal constructor");}} class Dog extends Animal{Dog() {System.out.println("Dog constructor");}} public class GenericDemo5 extends Animal{ public static void main(String r[]) { List l1 = new ArrayList(); //can add anything since no type here l1.add(new Dog()); l1.add(new Animal()); l1.add(30); met(l1); System.out.println(l1); } public static void met(List<? super Animal> l2) { l2.add(new Animal()); l2.add(new Dog()); System.out.println(l2); }} Even with Generic Instantiation(shown below) same output!! This …

Member Avatar
Member Avatar
+0 forum 11

class Sample1 { Sample1() {System.out.println("Sample1 const"); } void doStuff(){System.out.println("sample1 dostuff"); } } class Sample2 extends Sample1 { Sample2() {System.out.println("Sample2 const"); } } public class Sample3 extends Sample2 { Sample3() {System.out.println("Sample3 const"); } public static void main(String r[]) { new Sample3().go(); } void go() { super.doStuff(); } } The output is: Sample1 const Sample2 const Sample3 const sample1 dostuff My doubt is that super.doStuff() should invoke Sample2 method doStuff() if present. Why has it "propagated" upwards? I thought that happened only with no-arg super() being put implicitly (if not present) as first line of constructor.

Member Avatar
Member Avatar
+0 forum 4

My site needs a way to know whether a user is an admin or not in multiple pages. So is it safe to store whether a user is an admin or not in session variable? Or is there a better alternative (Maybe another superglobal variable?), It will only hold a number.

Member Avatar
Member Avatar
+0 forum 3

In one of the books I'm using to study Python I keep seeing things like: [CODE] class Application(Frame): super(Application, self).__init__(master): self.grid() self.bttn_clicks=0 self.create_widget"""which is another function in the class"""[/CODE] Why is the super necessary for the class if the class it's calling is itself?

Member Avatar
Member Avatar
+0 forum 3

This works with Python 2.7 [code]class B: def __init__(self, arg): print(arg) class C(B): def __init___(self, arg): super(C, self).__init__(arg) c = C('abc') # abc [/code]Here super() gives a TypeError: must be type, not classobj [code]from math import pi class Circle: """with Python3 object is inherited automagically""" def __init__(self, r): self.r = r def area(self): """a method of class Circle, first arg is self""" area = pi * self.r**2 return area class Cone(Circle): """class Cone inherits class Circle""" def __init__(self, r, h): super(Cone, self).__init__(r) # Python27 gives TypeError: must be type, not classobj self.r = r self.h = h def volume(self): """a …

Member Avatar
Member Avatar
+0 forum 4

[URL="http://www.ubuntu.com"]Ubuntu[/URL] has redeemed itself with its latest version 9.10 (Karmic Koala). I took a look at Ubuntu 9.10 on October 1st and have been playing around with it for a few days. My first impression is that it is good stuff--seriously good stuff. From the new, updated installer to the faster boot times, I'm impressed. Way to go Ubuntu developers, you deserve applause for this one. I didn't think that [URL="http://www.daniweb.com/news/story220512.html"]Ubuntu 9.04[/URL] (Jaunty Jackalope) was all that great. There weren't enough improvements over 8.10 to justify a whole new distribution or wasting a cute name on it. Karmic Koala's installer …

Member Avatar
Member Avatar
+7 forum 14

The End.