abstract-class

pure-specifier on function-definition

While compiling on GCC I get the error: pure-specifier on function-definition, but not when I compile the same code using VS2005. class Dummy { //error: pure-specifier on function-definition, VS2005 compiles virtual void Process() = 0 {}; }; But when the definition of this pure virtual function is not inline, it works: class ...

Problem deriving a user control from an abstract base class in website project

In a Visual Studio website, I have created a user control. This control is derived from a class (in App_Code) that is itself derived from System.Web.UI.UserControl. This is an abstract class with an abstract method. I then try to implement that method in the user control, but I get the following errors from Visual Studio: Error 1 ...

Difference between abstract class and interface

Possible Duplicate: Interface vs Base class A class implementing an interface has to implement all the methods of the interface, but if that class is implementing an abstract class is it necessary to implement all abstract methods? If not, can we create the object of that class which is implementing the Abstract class??? ...

c++ polymorphism of operator overloading

How can I make pure virtual function a operator+(); function. wheh ı do like this in base class int operator+()=0; compiler gives error . in derive class operator+() function compiler say that derive class cannot make . because following class is abstract I know that I cannot create object of abstract classes but now I try to make der...

Can anybody explain the working of following code...?

Can anybody explain the working of following code...? interface myInterface{} public class Main { public static void main(String[] args) { System.out.println(new myInterface(){public String toString(){return "myInterfacetoString";}}); System.out.println(new myInterface(){public String myFunction(){return "myIn...

Make an abstract class or use a processor?

I'm developing a class to compare two directories and run an action when a directory/file in the source directory does not exist in destination directory. Here is a prototype of the class: public abstract class IdenticalDirectories { private DirectoryInfo _sourceDirectory; private DirectoryInfo _destinationDirectory; prot...

can the keyword 'this' be used in an abstract class in java

I tried with below example, it is working fine. I expected it to pick sub-class's value since object won't be created for super class (as it is abstract). But it is picking up super class's field value only. Please help me understand what is the concepts behind this? abstract class SuperAbstract { private int a=2; public void f...

Why does Java allow multiple inheritance from interfaces but not from abstract/concrete classes

Possible Duplicate: Why there is no multiple inheritance in Java, but implementing multiple interfaces is allowed Why Java allows multiple inheritance from interfaces but not from abstract or concrete classes ...

Difference between Class Abstraction and Object Interfaces in PHP?

What is the difference between a Class Abstraction and an Object Interfaces in PHP? I ask because, I don't really see the point to both of them, they both do the same thing! So, what are the advantages of disadvantages using both against one or the other? Class Abstraction: abstract class aClass { // Force extending class to define...

Linking a template class using another template class (error LNK2001)

I implemented the "Strategy" design pattern using an Abstract template class, and two subclasses. Goes like this: template <class T> class Neighbourhood { public: virtual void alter(std::vector<T>& array, int i1, int i2) = 0; }; and template <class T> class Swap : public Neighbourhood<T> { public: virtual void alter(std::vect...

NHibernate DuplicateMappingException when mapping abstract class and subclass

I have an abstract class, and subclasses of this, and I want to map this to my database using NHibernate. I'm using Fluent, and read on the wiki how to do the mapping. But when I add the mapping of the subclass an NHibernate.DuplicateMappingException is thrown when it is mapping. Why? Here are my (simplified) classes: public abstract...

C++ destructor problem with boost::scoped_ptr

I have a question about the following code: #include <iostream> #include <boost/scoped_ptr.hpp> class Interface { }; class A : public Interface { public: A() { std::cout << "A()" << std::endl; } virtual ~A() { std::cout << "~A()" << std::endl; } }; Interface* get_a() { A* a = new A; return a; } int main(...

Class Mapping Error: 'T' must be a non-abstract type with a public parameterless constructor

Hi, While mapping class i am getting error 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method. Below is my SqlReaderBase Class public abstract class SqlReaderBase<T> : ConnectionProvider { #region Abstract Methods protected a...

Seam @Factory in abstract base class?

I've got a series of web actions I'm implementing in Seam to perform create, read, update, etc. operations. For my read/update/delete actions, I'd like to have individual action classes that all extend an abstract base class. I'd like to put the @Factory method in the abstract base class to retrieve the item that is to be acted upon. ...

Using WCF with abstract classes

How do I define DataContract for abstract classes in WCF? I have a class "Person" which I communicate successfully using WCF. Now I add a new class "Foo" referenced from Person. All still good. But when I make Foo abstract and define a sub class instead it fails. It fails on the server side with a CommunicationException, but that doesn...

Work around for being unable to make function templates virtual?

Hi, I have an abstract class vertex which represents an n-tuple. The element of the vertex can be of any type: ie, the vertice's components could be of type int, int, float or something. Because the vertex can have an arbitrary number of dimensions, I was thinking of making the class have a component setter like so: class vertex { ...

abstract class in java

Can someone please show me and example of an abstract class in Java? Something with a real world application (rather than a text-book sample) would be preferable. Thanks! ...

Using a generic type of a subclass within it's abstract superclass?

Hi there! Within my code a have the following abstract superclass public abstract class AbstractClass<Type extends A> {...} and some child classes like public class ChildClassA extends AbstractClass<GenericTypeA> {...} public class ChildClassB extends AbstractClass<GenericTypeB> {...} I'm searching for an elegant way how I can us...

Parameters implementing a certain interface and having a specific superclass: generics or instanceof?

I would love some help on a particular design. This is the code I wish worked: abstract class Square {...} abstract class Circle {...} interface JPGExportable {...} class SquareJPG extends Square implements JPGExportable {...} class CircleJPG extends Circle implements JPGExportable {...} interface Interface { draw(Square square);...

Can a django model have two abstract classes?

I have this models: class BillHeader(models.Model): billno = models.IntegerField(primary_key=True, blank=True) class BillData(models.Model): price = models.DecimalField(_('Price'), max_digits=12, decimal_places=2) amount = models.DecimalField(_('Amount'), max_digits=6, decimal_places=2) [... rest of the model ...] ...