abstract-class

Whats the utility of public constructors in abstract classes in C#?

If a public constructor in an abstract class can only be called by their derived classes it should be functionally equivalent to a protected constructor. Right? Is there any difference in declaring a public constructor, instead of a protected one, in an abstract class? What would you use it for? Why the compiler doesn't complaint? Than...

C# abstract Dispose method

I have an abstract class that implements IDisposable, like so: public abstract class ConnectionAccessor : IDisposable { public abstract void Dispose(); } In Visual Studio 2008 Team System, I ran Code Analysis on my project and one of the warnings that came up was the following: Microsoft.Design : Modify 'ConnectionAccessor.Dis...

Is the .NET Stream class poorly designed?

I've spent quite a bit of time getting familiar with the .NET Stream classes. Usually I learn a lot by studying the class design of professional, commercial-grade frameworks, but I have to say that something doesn't quite smell right here. System.IO.Stream is an abstract class representing a sequence of bytes. It has 10 abstract method/...

xcode compiler see a class as abstract but it's not!

Hi, I'm working on a C++ command tool project that depends on a third party architecture called ACE (adaptive communication environment). I'm new to Xcode and this is what I've done to have my command tool project "sees" the ACE library. compile the ACE library so that I have a bunch of dynamic libraries: xxx.dylib add the libraries a...

Groovy on Grails: Abstract Classes in GORM Relationships

Grails GORM does not persist abstract domain classes to the database, causing a break in polymorphic relationships. For example: abstract class User { String email String password static constraints = { email(blank:false, nullable:false,email:true) password(blank:false, password:true) } static hasMany = [membership:GroupMembers...

How to limit subclassing of public abstact class to types in same assembly and thus allow protected members typed to internal types.

This question is similar to c# internal abstract class, how to hide usage outside but my motiviation is different. Here is the scenario I started with the following: internal class InternalTypeA {...} public class PublicClass { private readonly InternalTypeA _fieldA; ... } The above compiles fine. But then I decided that I ...

Abstract class in c++

Hi, Let's say I've got class: class Bad_Date { private: const char* _my_msg; public: const char* msg() const { return _my_msg; } }; And I would like to not be able to create any object of this class but I don't really want to put anything else there and make it pure virtual fnc. Is there any other way to make this class abstract or ...

Are empty abstract classes a bad practice, and why?

We have several empty abstract class in our codebase. I find that ugly. But besides this very stupid reason (ugliness), should I refactor it (into empty interface e.g.) ? Otherwise, the code is robust and well tested. So if it's only for a "aesthetic" reason, I will pass and let the empty abstract classes remain. What do you think? ED...

In nHibernate, can I map an abstract base class to a collection?

I have a base class for content items in a CMS I'm building. It's currently marked abstract because I only want derived classes to be instantiated. Derived classes like BlogPost, Article, Photo, etc. are set up as a joined subclass to my ContentBase class in nHibernate. I'm trying to set up a many-to-many mapping between this class an...

Can I change dll-interface without recompilation exe-file?

I have an abstract class in my DLL. class Base { virtual char * First() = 0; virtual char * Second() = 0; virtual char * Third() = 0; }; This dinamic library and this interface are used for a long time. There is my mistake in my code. Now I want to change this interface class Base { virtual const char * First() const = 0; ...

interface vs abstract class

In php :: Please explain when i should use interface and when i should use abstract class? And how i can change my abstract class in to an interface? ...

Extend abstract singleton class

If you had a factory class that creates new objects of some kind, and that factroy class is a singleton, like this: class Database_Factory extends Base_Factory { private static $factory; private $objects = array(); public function __get($profile) { // check for object and return it if it's created before } ...

How can I have both abstract and virtual methods in one class?

In the following parent class SqlStatement, how can I make Initialize() abstract but keep Execute() virtual? using System; using System.Collections.Generic; namespace TestSql28374 { class Program { static void Main(string[] args) { object item = new object(); List<string> properties = new...

C++/CLI : How do I declare abstract (in C#) class and method in C++/CLI?

What is the equivalent of the following C# code in C++/CLI? public abstract class SomeClass { public abstract String SomeMethod(); } ...

Abstract keyword in PHP

Hey, I'm quite experienced with PHP but I have no idea what the keyword abstract does when it comes down to object orientated programming. Can anyone explain in plain english what it can be used for? What situations would I use the abstract keyword in? How does it change the class/interface? ...

What is an alternative to having static abstract methods?

I'm having some problems trying to figure out how to solve a problem without being able to have static method in an abstract class or interface. Consider the following code. I have many Wizards that inherit from AbsWizard. Each wizard has a method GetMagic(string spell) that only returns magic for certain magic words, yet all instances o...

abstract class and using array polymorphically

i'm just reading meyers "More Effective C++ 35 New Ways" - item 33, and he suggest there always to inherit from an abstract base class, and not a concrete. one of the reason he claims, which i can't quite get , is that with inheriting from an abstract class, treating array polymorphically (item 3 in the book) is not a problem. can some...

Fluent nHibernate Abstract class (non) Mapping problem

I have a base class, which has 2 derived class. Each derived class has a mapping file (they base class has non and it's abstract) Each derived class has an object that points to itself (which is defined in the base class); class Base { Base myManager; } class Derived1 : Base { } Class Derived2 : Base { } for each derived class ...

Iphone SDK selector or abstract class

Hi, I am developing a special type of view controller for an iPhone component library. I have got the who view controller working well, but I need to change it so that it works in one of two ways: Either it is an abstract class which you must subclass and provider the implementation for a specific method which the controller will call...

Allow field in a child class to be of a type descended from the type of the field in the parent class

I have the following setup (simplified, obviously): An abstract class, with an A object and an abstract method abstract public class X { protected A myA; abstract public int MethodForX(); } Two inheriting classes, each of which override the method. However instead of using an A object they use a B and C object, each of which ...