abstract

Delphi 6: Force compiler error on missing abstract class methods?

I'm using Delphi Pro 6. Right now, the only way to know if a class is missing a base class abstract method is to wait for the IDE to emit a "constructing instance of {derived class} containing abstract method {base class.abstract method name}" warning or to wait for a runtime Abstract Error method when an attempt to call the missing met...

ptr_map and pointer

Hello, I'm using ptr_map from boost for storing objects derived from some base abstract type. class Entity { virtual void foo() = 0; }; class Entity1 : public Entity {}; class Entity2 : public Entity {}; boost::ptr_map<string, Entity> someMap; // We could store pointers for abstract type Inserting works great: someMap.insert("someKe...

How do you set specific properties to a class created by an abstract factory?

Is it possible to have concrete factories create concrete classes with type specific parameters for them using the abstract factory pattern? Or do the different concrete classes created by their respective concrete factories need to to have the same fields? Best regards, Christian ...

How can I inherit an inner class using an abstract base class?

I'm trying to create a test class which organizes its test methods using inner classes. I would like for this class to be abstract with the ability to set a static property so this property can be injected. Here's an example of what I'm talking about: [TestClass] public abstract class BaseUnitTest { public static string InjectedPro...

How can I force a Constructor to be defined in all subclass of my abstract class.

Hi, I have an abstract class A that define abstract methods. This means that, for a class to be instanciable, all the abstract method have to be implemented. I'd like all my subclasses to implement a constructor with 2 ints as parameters. Declaring a constructor defeats my purpose, as I want the constructor defined in subclasses and ...

Best way to share Java implementation between concrete JPA classes?

I have about 10 different entities in my J2EE application that right now share the exact same implementation. They all inherit from the same generic abstract class that has been annotated as a @MappedSuperclass, but this class contains none of the implementation I have repeated in all the concrete subclasses. If I could, I'd put all...

Benefits of using an abstract classes vs. regular class

I have decided to start doing small coding projects on my own that focus on code quality instead of code quantity and have a question about the use of abstract classes. Now I know the differences between abstract classes and interfaces with the biggest one (I think) being that interface allow you to only define methods that need to be i...

javac claims that I'm not overriding a method in an abstract class implementation when I clearly am

I'll make this as short and to the point as possible, but it's kind of a complex issue. I'm writing in Java on a Linux platform, for whatever that's worth. Short version of the goal: I want to have an abstract class called Client that acts as a generic container for client connections. Client should thread each of its connections. I ...

F#: Function with flexible type argument and return value?

I'm trying to write a function that accepts a certain type or any of its sub-types as one of its arguments, then returns a value of a type or any of its sub-types. [<AbstractClass>] type Spreader () = abstract Fn : unit -> unit type Fire () = inherit Spreader () override self.Fn () = () type Disease () = inherit Spread...

PHPunit mockobject abstract and static method

Hi, I would like to test a method from an abstract class. In this class is there a abstract method with is static. I use PHPUnit. With normal abstract methods it works: <?php abstract class AbstractClass { public function concreteMethod() { return $this->abstractMethod(); } public abstract function abstractMethod(); } cl...

C++ inheritance question

Hello! I have the following problem in application architecture and am willing to solve it (sorry for a lot of text). I am building a game engine prototype and I have base abstract class AbstractRenderer (I will use C++ syntax, but still the problem is general). Assume there are some derived implementations of this renderer, let's say...

What types of abstract interfaces are most common in practice

I wasn't completely sure how to phrase what I wanted to ask in the title so I'll try to clarify it better in what follows. For C++ software library developers, what abstract interfaces do you find yourselves rewriting often between projects/jobs? For instance, I would imagine that it is fairly common practice for different projects to ...

static abstract methods in c++

I have an abstract base class class IThingy { virtual void method1() = 0; virtual void method2() = 0; }; I want to say - "all classes providing a concrete instantiation must provide these static methods too" I am tempted to do class IThingy { virtual void method1() = 0; virtual void method2() = 0; static virtual IThingy Fa...

Java Instantiate Abstract Class or Partially Implemented Interface

I have an interface that has about 20 methods (huge). I want to create a single instance for testing purposes, but I only need to override one method. What's a good way to get an instance of this class with the overridden method without having to define the whole class with a tone of "//TODO: implement this" methods. Mocking frameworks...

Private or Protected Set for a MustOverride Property

I'd like to have a Private or Protected "Setter" for a property that also happens to be an abstract (MustOverride). I'm porting some code from C# to VB and in C# this is pretty straight forward. In VB not so much (for me anyway). Some code... In C#... public abstract class BaseClassWithAnAbstractProperty { public abstract int AnAb...

Scala abstract path dependent type problem

Does anyone know what's going on here with this compiler error? The error goes away if I don't extend INode. trait AbsTypes { type TKey type TValue } trait INode extends AbsTypes { def get(key : TKey) : TValue def set(key : TKey, v : TValue) : INode } class ANode[TKey,TValue]( val akey : TKey, val aval : TValue ) e...

Scala abstract path dependent type problem part 2

Couple of questions on scala abstract types. Do I have to use parameterized [] types if I want to use the type in a constructor value? ie. is it possible to have a class with abstract constructor parameter types? If I get rid of [T1,T2] and use INode#TKey and INode#TValue as the constructor parameter types, what am I doing? I get confu...

Using extends in Java gives enclosing instance error

I'm trying to use extends (inheritance) in Java. I made a quick abstract class to extend from, and then extended it. However my IDE now is saying that "An enclosing instance that contains abstract_class is required" and gives my constructor for the derived classes big error lines. What on earth is it going on about? The abstract class do...

Set transformation

I'm looking for a way to transform a set, and having trouble. This is because the requirements are rather rigorous. Set A contains a bunch of integers, the details are really irrelevant. Set B contains a bunch of integers, such that: Each value in A directly maps to one and only one value in B. Each bit is true in one, and only one, v...

Django: Accessing method on child different child classes through common name

I have an abstract base class for defining common attributes shared by different user profiles. class Profile(models.Model): ... def has_permissions(self, project): ... class Meta: abstract = True class Standard(Profile): ... class Premium(Profile): ... Now I would like to check the permission of a certa...