abstract-class

Django subclasses having unique IDs

Assuming I have an abstract class ("AbstractClass") and two subclasses ("Subclass1" and "Subclass2"), two separate database tables will be created to hold instances of Subclass1 and Subclass2. These database tables currently number normally, from 1 upwards. Is there a way to ensure the IDs of all implementing subclasses are unique betwe...

Android: Extending a custom abstract Activity

Hello, I created an abstract Activity which extends the android.app.Activity. Then I created an activity extending my abstract one. [1] Everything is fine with ant, but eclipse showed an error in the manifest saying that my activiy did not exists, so I regenerate the class files and the error in the manifest is gone. But now eclipse s...

How do I make an abstract class properly return a concrete instance of another abstract class?

I recently reworked one of my own libraries to try out separating interface from implementation. I am having on final issue with a class that is meant to return an instance of another class. In the interface definition, I do something like struct IFoo { virtual const IBar& getBar() = 0; } and then in the concrete Foo getBar look...

Abstract generic classes taking type parameters that are themselves derived from that class

Do you consider it an acceptable or a bad practice to create an abstract generic class that takes as a type parameter a class that derives from itself? This allows the abstract generic class to manipulate instances of the derived class and in particular the ability to create new() instances of the derived class as necessary and can he...

Why private access specifier in an abstract class in Java even though we cannot create an instance of an abstract class?

I know it is not a good coding practice to declare a method as private in an abstract class. Even though we cannot create an instance of an Abstract, why there is private access specifier within an abstract class , what is the scope of it within an abstract class? In which scenario does private access specifier are used in an abstract c...

When and Why to use abstract classes/methods?

I have some basic questions about abstract classes/methods.I know basic use of abstract classes is to create templates for future classes. But are there any more uses of them ? When should you prefer them over interfaces and when not ? Also when are abstract methods useful ? ...

Java insuring that an object passed to a method extends a given class.

What would be the best way to check in an object being passed into a method extended a given class? Currently i have a method that takes a ByteBuffer of data to send and a 'player' class that i wrote, and queues the data up on the IO server to be sent to the client: public void send(ButeBuffer toSend, Player player) { // prep the byt...

Must declare a body becase it is not marked abstract, extern or partial

Hello all. I'm a tool, tired and completely out of my depth!! I have created the following class based on some old code so one has kindly given me. However, I cannae get past the error as described in the title. The classe is as follows using System; using System.Collections.Generic; using System.Linq; using System.Web; using System....

How do I call an overridden method one level up in java?

I have an abstract base class. I have a class2 that extends base class. I have a class3 that extends class2. I have overridden abstract baseclass.method1 in both class2 and class3. in class3.method1, I call super.method1 and the error I get is that I can't directly call the abstract method in baseclass. but I don't want to, I j...

Problem With Repository Pattern & Abstract Classes

Hi Guys, Come across a problem with the repository pattern combined with the use of abstract classes. I have a repository which implements a single method returning an ICollection of an abstract type. Here's my abstract class: public abstract class Location { public abstract string Name { get; set; } public abstract LocationTyp...

Java Abstract Classes

I wonder what is the difference in Java between an abstract class and a class that has all its methods abstract? I mean, is an abstract class just a class whose methods automatically get abstract? ...

Is it possible to create an instance of an abstract class in C#?

Can I create instance of abstract class in C#/.net like in Java ? Additional Info I think a lot of us does not understand what do I mean? So, In java I can create abstract class like this : Simple abstract class : /** * @author jitm * @version 0.1 */ public abstract class TestAbstract { public abstract void toDoSmth(); } Cod...

Can I teach dynamic_cast<>() new tricks?

Is there a way in C++ to construct your class such that given a pointer to your class you can instruct dynamic_cast<>() how to cast to another class for which you are wrapping the implementation? Would operator cast do the trick? Imagine I have an Abstract interface base class and derive a concreteA from this as well as concreteB, but ...

How can i choose Abstract class or Interface..?

Possible Duplicates: Interface vs Base class Abstract classes vs Interfaces How can we take decision about when we have to use Interface and when Abstract Class..?? Any idea..?? Thank in advance! ...

Abstract class in LINQ2SQL for sharing common methods

Hi, I'm having trouble trying to implement a shared method/property between two classes created by the linq2sql designer. My two classes have two main properties (coming from the db model): public partial class DirectorPoll { public bool Completed {get; set;} public bool? Reopen { get; set; } //more properties } public par...

Call the constructor of the unknown children

Hi! I want to call the constructor; class anAbstractClass { public: anAbstractClass(inputdatatype){/*blablabla*/} }; class aChield : public anAbstactClass { /* ... */ } void _engine::initShader(_anAbstractClass** inShader) { *inShader = new /*???*/(inputdata for the construcor) } aChield* theChield; _engine* myEngine = new _engi...

Abstract Factories not possible in php < 5.3?

I was working on an abstract class to save on some code for a couple of classes. These classes are all factories that instantiate themselves through different static calls. I could save some code by putting all those methods in an abstract class. However, I ran into a late static binding problem... since our web host isn't using 5.3 or...

Should an abstract class' destructor be pure virtual?

I think virtual alone is generally sufficient. Is there another reason to make it pure virtual than to force derived classes to implement their own destructor? I mean if you allocate something in your class' constructor you should impement your own destructor - if your class is derived or not. Doesn't count as answer as I already know:...

[C++] Clone abstract base class (without meddling with derived)

Hello all. I'm experiencing a challenging problem, which has not been solvable - hopefully until now. I'm developing my own framework and therefore trying to offer the user flexibility with all the code complexity under the hood. First of all I have an abstract base class which users can implement, obviously simplified: class IStateTr...

How can you explain the difference between an interface and an abstract class to a non-programmer?

Possible Duplicate: When to use an interface instead of an abstract class and vice versa? Hi, I am teaching OOP concepts to non-programmers. I wanted to know how can you explain the difference between an interface and an abstract class. What I am actually looking for, is a real world example that can help highlight the differe...