inheritance

Generics and Derived Classes .NET 3.5

Consider the following where class "Circle" inherits from "Shape": dim objListOfCircles as new List(of Circle) DrawShapes(objListOfCirlces) Private sub DrawShapes(byref objListOfShapes as List(of Shape)) for each objShape as Shape in objListOfShapes objShape.Draw() next end sub I can't get this to work. What is the explainati...

how to not inherit? or how to reset inherited width to the value before? (css)

I installed 'Thank you plugin' but the button on my test site but the button looks strange. I found why. Because it inherits #commentform textarea { width: 45%;} from my theme. If I remove the width from css the button looks ok. Any idea how I can fix that? Of course I do not want to remove width for #commentform textarea. Can I do some...

Why does this program hang?

I have the following code which is seems to be lead to the infinite loop: struct X { void my_func( int ) { std::cout << "Converted to int" << std::endl; } }; struct X2 : X { void my_func( char value ) { my_func(value); } }; What is the problem with it? ...

How to use derived class shared variables in shared methods of base class

Hi guys, I am trying to add shared members in derived classes and use that values in base classes... I have base class DBLayer public shared function GetDetail(byval UIN as integer) dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin) .... end function end class my derived class class Us...

Alternative initialize for a Class to avoid processing already known information

I have a class, Autodrop, that contains several methods , a.o. 'metadata', that call an external API (dropbox). They are slow. However, I already often have that metadata around when initializing the AutodropImage, so I should make the methods smarter. What I have in mind is this: class Autodrop include Dropbox attr_reader :path ...

C++ inheritance and method overloading

Why C++ compiler gives this error? Why i can access lol() from B, but can not access rofl() [without parameters]. Where is the catch? class A { public: void lol(void) {} void rofl(void) { return rofl(0);} virtual void rofl(int x) {} }; class B : public A { public: virtual void rofl(int x) {} }; int _tmain(int argc, _TCHAR*...

If class inherited many times can be slower ?

When i try to create good object hierarchy which will help to write less code and avoid to use unnecessary fields ,i feel myself free to create many base classes for good grouping which is usually abstract. What can be disadvantage of doing it like that ? Many times inherited class can be slower ? To see many unnecessary abstract classe...

Questions while designing OOP hierarchy

Hello When creating inheritance hierarchy, i get confused .Abstract Base class should contain only commonly used stuffs for inherited classes.But knowing which is commonly used methods,fields and properties is not possible while designing.So i feel free myself to grouping them with abstract classes which inherits hierarchicaly. This is ...

how to implement inheritance in hibernate ??

I have a entities as: BaseEntity --> Which contains user login info like createdBy, createdTime, EditedBy, editedTime Employee --> which contains employee information like name, address, etc... RegularEmployee --> which contains salary, bonus tht kind of fields and ContactEmployee --> which contains HourlyRate, contactPeriod etc.... ...

Inheritance question / problem

I'm creating a custom Layout for android. The layout implementation is exactly the same, but once I need to extend from RelativeLayout, and once from LinearLayout. class Layout1 extends LinearLayout { // methods and fields } class Layout2 extends RelativeLayout { // the same EXACT methods and fields } How can I use inheritance to avo...

problem with template inheritance

I'm trying to understand whay i get an error on this code: (the error is under g++ unix compiler. VS is compiling OK) template<class T> class A { public: T t; public: A(const T& t1) : t(t1) {} virtual void Print() const { cout<<*this<<endl;} friend ostream& operator<<(ostream& out, const A<T>& a) { out<<"I'm ...

inheritance problem OOP extend

If a Father is a Parent and a Parent is a Person and a Person has a Father I create the following: class Person{ Father father; } class Parent extends Person{} class Father extends Parent{} Instances: Person p1 = new Person(); Person p2 = new Person(); p1.father = p2; //father is of the type Father This doesn't work... Now tr...

C++ - Where to code a member function for an inherited object.

Hello! I have a few classes (heat, gas, contact, pressure) inheriting from a main one (sensor). I have a need to store them in a vector<Sensor *> (part of the specification). At some point in time, I need to call a function that indiscriminately stores those Sensor *. (also part of the specification, not open for discussion) Somethi...

Inheriting the main method

I want to define a base class that defines a main method that instantiates the class, and runs a method. There are a couple of problems though. Here is the base class: public abstract class Strategy { abstract void execute(SoccerRobot robot); public static void main(String args) { Strategy s = new /*Not sure what to...

C++ Iterators and inheritance

Have a quick question about what would be the best way to implement iterators in the following: Say I have a templated base class 'List' and two subclasses "ListImpl1" and "ListImpl2". The basic requirement of the base class is to be iterable i.e. I can do: for(List<T>::iterator it = list->begin(); it != list->end(); it++){ ... } ...

Javascript Inheritance and Arrays

Hi all! I am trying to define a javascript class with an array property, and its subclass. The problem is that all instances of the subclass somehow "share" the array property: // class Test function Test() { this.array = []; this.number = 0; } Test.prototype.push = function() { this.array.push('hello'); this.number = 10...

Java Inheritance doubt in parameterised collection

It's obvious that a parent class's object can hold a reference to a child, but does this not hold true in case of parameterised collection ?? eg: Car class is parent of Sedan So public void doSomething(Car c){ ... } public void caller(){ Sedan s = new Sedan(); doSomething(s); } is obviously valid But public void do...

Java/JAXB: Unmarshall Xml to specific subclass based on an attribute

Is it possible to use JAXB to unmarshall xml to a specific Java class based on an attribute of the xml? <shapes> <shape type="square" points="4" square-specific-attribute="foo" /> <shape type="triangle" points="3" triangle-specific-attribute="bar" /> </shapes> I would like to have a List of Shape objects containing a triangle and ...

Objective-C protocol vs inheritance vs extending?

I have a couple classes that have nearly identical code. Only a string or two is different between them. What I would like to do is to make them "x" from another class that defines those functions and then uses constants or something else to define those strings that are different. I'm not sure if "x" is inheritance or extending or wh...

How am i overriding this C++ inherited member function without the virtual keyword being used?

I have a small program to demonstrate simple inheritance. I am defining a Dog class which is derived from Mammal. Both classes share a simple member function called ToString(). How is Dog overriding the implementation in the Mammal class, when i'm not using the virtual keyword? (Do i even need to use the virtual keyword to override membe...