inheritance

Simple Inheritance Question

I get a few errors saying: "The name 'title' does not exist in it's current context" "The name 'author' does not exist in it's current context" "The name 'genre' does not exist in it's current context" "The name 'pages' does not exist in it's current context" using System; using System.Collections.Generic; using System.Text; namespace...

Inheritance or identifier

Hi! Does anyone here have opinions about when to user inheritance and when to use an identifier instead? Inheritance example: class Animal { public int Name { get; set; } } class Dog : Animal {} class Cat : Animal {} Identifier example: class Animal { public int Name { get; set; } public AnimalType { get; set; }...

.Net Inherited Control Property Default

Hello fellows Im trying to make a simple "ButtonPlus" control. the main idea is to inherit from the button control and add some default property values (such as font,color,padding...) No matter how i try, the WinForm always generates (or "serializes") the property value in the client forms the whole point is to have minimal and clean c...

How to override "inherited" z-indexes?

I am needing to override the notion of inherited z-indexes. For instance in this code <style> div{ background-color:white; top: 0px; bottom: 0px; left: 0px; right: 0px; } </style> <div style="position: fixed; z-index: 2;"> div 1 <div style="position: fixed; z-index: 3;"> div 2 </div> </div> <div style="positio...

"Undefined Symbols" when inheriting from stdexcept classes

Here is an exception defined in <stdexcept>: class length_error : public logic_error { public: explicit length_error(const string& __arg); }; Here is my exception: #include <string> #include <stdexcept> using namespace std; class rpn_expression_error : public logic_error { public: explicit rpn_expression_error(const string...

How can I implement an abstract singleton class in Java?

Here is my sample abstract singleton class: public abstract class A { protected static A instance; public static A getInstance() { return instance; } //...rest of my abstract methods... } And here is the concrete implementation: public class B extends A { private B() { } static { instance = new...

Is there a way to model table inheritance using MySQL Workbench?

Is there a way to model table inheritance using MySQL Workbench? I'd like the ERD to look similar to the left side of this image: ...

How to Correct & Improve the Design of this Code?

HI Guys, I've been working on a little experiement to see if I could create a helper method to serialize any of my types to any type of HTML tag I specify. I'm getting a NullReferenceException when _writer = _viewContext.Writer; is called in protected virtual void Dispose(bool disposing) {/*...*/} I think I'm at a point where it alm...

Any way to force classes to have public static final field in Java?

Is there a way to force classes in Java to have public static final field (through interface or abstract class)? Or at least just a public field? I need to make sure somehow that a group of classes have public static final String TYPE = "..."; in them. ...

What's the difference between isPrototypeOf and intanceof in Javascript?

Hi In some of my own older code, I use the following: Object.prototype.instanceOf = function( iface ) { return iface.prototype.isPrototypeOf( this ); }; Then I do (for example) [].instanceOf( Array ) This works, but it seems the following would do the same: [] instanceof Array Now, surly this is only a very simple example. My ...

How to invalidate / refresh a domain instance association?

There is a bug in Grails preventing me from using removeFrom* when the node I'm trying to remove is extending the collection type. Removing the node directly from the association won't update the second level cache. A hasMany B Is there any way to manually invalidate or force a reload on an association cache? Invoking refresh() on...

CSS inheritance: applying selector for itself and every descendant

Get a custom user CSS and type this .answered-accepted { color: white !important; background: #090 !important; } Now go to answers.unity3d and look for an accepted answer. The design looks bad, because the <strong> in there overrides the customization. The fix I've found is this: .answered-accepted, .answered-accepted * { color...

Unique ID Defined by Most-Derived Class accessible through Base Class

Okay, so, the idea is that I have a map of "components", which inherit from componentBase, and are keyed on an ID unique to the most-derived*. Only, I can't think of a good way to get this to work. I tried it with the constructor, but that doesn't work (Maybe I did it wrong). The problem with any virtual, etc, inheritance tricks are tha...

Delphi 7 inheritance

Have 6 forms, 1 Base and 5 inherited.The Base has the following snippet: procedure TMechan.Open1Click(Sender: TObject); begin if OpenDialog1.Execute then Form1.Memo1.Lines.LoadFromFile(OpenDialog1.FileName ); CopyCylMemoToRecord; ShowMechanicalValues; end; Since this snippet is in the Base it's also inherited by 5 others. P...

Derived class linker - is this wrong?

We have this situation: Window Keyboard ^ ^ | / ApplicationWindow so class Window { } class Keyboard { } class AppWindow : public Window, public Keyboard { } Now, Keyboard wants to access a property in ApplicationWindow, for example,...

Inheritance of closure objects and overriding of methods

I need to extend a class, which is encapsulated in a closure. This base class is following: var PageController = (function(){ // private static variable var _current_view; return function(request, new_view) { ... // priveleged public function, which has access to the _current_view this.execute = function() { ...

Generic calls to OnResetDevice() and OnLostDevice()

This is kind of a COM question to do with DirectX. So, both ID3DXSprite and ID3DXFont and a bunch of the other ID3DX* objects require you to call OnLostDevice() when the d3d device is lost AND OnResetDevice() when the device is reset. What I want to do is maintain an array of all ID3DX* objects and simply call OnResetDevice() and OnLos...

Why does the arrow go up in inheritance?

When you draw an inheritance diagram you usually go Base ^ | Derived Derived extends Base. So why does the arrow go up? I thought it means that "Derived communicates with Base" by calling functions in it, but Base cannot call func...

How to treat an instance variable as an instance of another type in C#

I have a simple inheritance heirarchy with MyType2 inheriting from MyType1. I have an instance of MyType1, arg, passed in as an argument to a method. If arg is an instance of MyType2, then I'd like to perform some logic, transforming the instance. My code looks something like the code below. Having to create a new local variable b feel...

Inheritance issue

hi Friends i am facing a issue in Inheritance i have a interface called Irewhizz interface irewhzz { void object save(object obj); void object getdata(object obj); } i write definition in different class like public user:irewhzz { public object save(object obj); { ....... } public object getdata(object obj); { ...