inheritance

Why are C++ inheritance mechanisms opaque?

Why, for example, is there no language support to examine a vtable? Why can't I replace a member function with a new one? I have a gut feeling that there are ways to put such features to good use. Are there any other languages out there which allow me to do such things? ...

class method inheritance question

Can anyone recommend good tutorial or a book on topics : class, methods, inheritance OOP etc .. to get general ideas .. and with some examples .. programming language is not important. tnx ...

Hiding Properties in Derived C# Classes

I have four classes which share some arrangement of four properties. I have currently set the base class to be abstract with each property marked as virtual. Then in each of the four derived classes I am overriding the properties which it uses and ignoring the others. The problem is that I can still access all properties in each of the ...

java inheritance versus composition (implementing a stack)

Hey everyone, I am trying to implement a Stack in java (using the list interface: Interface List). I want to implement it two different ways: using composition and inheritance. For inheritance, so far I have: import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.ListIterator; public cl...

Difference between MyClass.prototype = new Object() and MyClass.prototype = Object

Hi, could anyone please tell me, where in Javascript the difference between MyClass.prototype = new Object(); //or ... = {} and MyClass.prototype = Object; is? And if there is no difference in the result, which one is the best-practise-way-to-go? Thank you, m ...

Is __autoload() called for parent classes of autoloaded classes?

In the main.php, autoload is added and a new object is created. function __autoload ($class) { require_once($class . '.php'); } ... $t = new Triangle($side1, $side2, $side3); Then in Triangle.php, Triangle extends Shape as following. class Triangle extends Shape { ... So there is another class in Shape.php which is abstract cla...

In C++, how can I implement this OOP concept?

I have two implemented classes: class DCCmd : public DCMessage class DCReply : public DCMessage Both are protocol messages that are sent and received both ways. Now in the protocol implementation I'd need to make a message queue, but with DCMessage being abstract it won't let me do something like this: class DCMsgQueue{ pri...

c# picturebox inheritance for card game

I'm woking on a card game for my Intro to OOP paper. The game itself meets the specifications but I am now playing around with it for my own gratification and learning. I have a card class that contains and image, its rank and suite. On the GUI I use picture boxes to display the image stored in the respective cards (which are stored in ...

How do I make a Rails ActiveRecord dependent on an attribute?

I have created an ActiveRecord for a customer, and now they would like it so when it's destroyed, it is actually kept around for a manual rollback. What I would like to do is create a boolean attribute called 'active', and it defaults to 1. When a record is destroyed, the attribute is toggled to 0. I know I could change all my queries...

ArgumentException when creating instance of object that inherits from ObjectContext

I'm loosely following an excellent series of blog posts by Kazi Manzur Rashid as a learning exercise for learning how to implement some new (for me at least) design patterns, but I'm getting trouble from the start. I've basically copied his code for the Database, RepositoryBase and RepositoryBaseTests classes, but when I try to run the ...

Multiple Windows in PyQt4

I have a PyQt program used to visualize some python objects. I would like to do display multiple objects, each in its own window. What is the best way to achieve multi-window applications in PyQt4? Currently I have the following: from PyQt4 import QtGui class MainWindow(QtGui.QMainWindow): windowList = [] def __init__(self,...

C++ Overridden method not getting called

Shape.h namespace Graphics { class Shape { public: virtual void Render(Point point) {}; }; } Rect.h namespace Graphics { class Rect : public Shape { public: Rect(float x, float y); Rect(); void setSize(float x, float y); virtual void Render(Point point); private: float sizeX; float s...

ActiveRecord table inheritence using set_table_names

Hi, I'm using ActiveRecord in Ruby on Rails. I have a table named documents(Document class) and I want to have another table data_documents(DataDocument) class which is effectively the same except for having different table name. In other words, I want two tables with the same behavior except for table name. class DataDocument < Docum...

Can I have different copies of a static variable for each different type of inheriting class

I want to have the same static variable with a different value depending on the type of class. So I would have public class Entity { public static Bitmap sprite; public void draw(Canvas canvas, int x, int y) { canvas.drawBitmap(sprite, x, y, null); } } public class Marine extends Entity { } public clas...

Opinions about list item and its class design

I'm currently designing a list widget to add to my widget engine. Since every elements visual aspects are defined outside the code I can reuse most of the code base. For instance tab buttons are actually checkboxes. New templates take time to implement since they should have at least a viewer in design application. I already have an imp...

Override member data in subclass, use in superclass implementation?

In Java, is it possible to override member data in a subclass and have that overridden version be the data used in a super class's implementation? In other words, here's what I am trying to get to happen, and it's not happening: abstract public class BasicStuff { protected String[] stuff = { "Pizza", "Shoes" }; public ...

C++ Templates and Inheritance

Let's say I have a simple Server with a template which accepts a Client as it's template argument: template<class T> class Server<T>{ Server(int port); } and a Client is defined something like this: class Client{ Client(Server<Client> *server, // <-- int socket); }; But I also want say, have the class User inheri...

Declaring Enums across derived classes

Hi, I am developing a program in VB.NET. I have an enum called PriceType that is declared in a super class ItemPriceBase. There are 3 classes that derive from ItemPriceBase - ItemPriceMeasured, ItemPriceNDI and ItemPriceExtraCost. The subset of PriceTypes for these classes are totally unique from each - Measured prices are 1 to 6, NDI...

Redefine a derived class' variable

Is the following valid? Or how can I get something close to this. template<class T_> class Template { //something }; class Parent { public: Template<Parent> variable; Parent() : variable(this) { } }; class Derived : public Parent { public: Template<Derived> variable; Derived() : Parent() { } } Thanks in advance. ...

IList<Type> to IList<BaseType>

I have a few classes: class Vehicle { } class Car : Vehicle { } I have a list of the derived class: IList<Car> cars; I would like to convert the list to its base class, and have tried: IList<Vehicle> baseList = cars as IList<Vehicle>; But I always get null. Also cars is IList<Vehicle> evaluates to be false. Gr...