abstract-class

Expression<Func<T,bool>> - How to Handle Ambiguous Method Signatures?

Hi Guys, I have an interface contract that looks like this: ICollection<FooBar> FindByPredicate(Expression<Func<FooBar,bool>> predicate); ICollection<Foo> FindByPredicate(Expression<Func<Foo,bool>> predicate); ICollection<Bar> FindByPredicate(Expression<Func<Bar,bool>> predicate); Foo and Bar are concrete classes which inherit from t...

What is the difference between an abstract class and an interface?

Possible Duplicate: Interface vs Abstract Class (general OO) Can I ever instantiate an Abstract class? If so, why would I not make all my non-sealed classes abstract? If I can't instantiate it, then what is the difference from an interface? Can the abstract class have "base" class functionality? Is there more to the differ...

How do I delete a node from linked list? c++

How can I delete a node (between two nodes) from a single linked list without passing any parameters to the class function? For example, I have a list of 6 nodes with one head node and i want to delete 2 of them (without prior knowledge of their address or position) from a class function, how would i do that? void WordList::deleteNod...

Avoiding many inheriting classes

Lets say I have this class (just as an example): internal class Packet { private readonly UInt32 _length; private readonly Byte _type; private readonly UInt32 _requestId; } There are many different types of packets each of which inherit from this class and each packet type can have any number of properties of varying typ...

professional usage of abstract class for translation

the code below is not giving me the answer i want, i don't know where is the problem? FR is the translation of EN (exactly like .properties file) i want to read the translation from the FR.java file if i want to reach the hello variable of fr.java or en.java from the index.jsp page. but code i wrote gives me the value from Lang.java St...

PHP Class Logic

My question is rather simple, given: class MyClass{ function a(){ echo "F.A "; } function b(){ echo "F.B "; } } $c=new MyClass; $c->a()->b()->b()->a(); So that it will output: F.A F.B F.B F.A What changes to code need to be made for this to work, or should it work as is or even just what this is called...

How to query abstract-class-based objects in Django?

Let's say I have an abstract base class that looks like this: class StellarObject(BaseModel): title = models.CharField(max_length=255) description = models.TextField() slug = models.SlugField(blank=True, null=True) class Meta: abstract = True Now, let's say I have two actual database classes that inherit from StellarObjec...

Simple Handmade PHP Template Engine not working! Help Please

These are the class definitions <?php abstract class MyTemplate { protected $arrayOfSpaces; protected $arrayOfVariables; protected $output; protected abstract function __construct(); function outputHTML(){ echo $output; //Apparently, the problem is HERE. <<<<>>>>> } } class MyTemplateMain extends MyTemplate { ...

How to call base class method?

Say I have classes declared like this: public abstract class IdentifiableEntity { public boolean validate() { return true; } } public class PreferenceCategory extends IdentifiableEntity { public boolean validate() { return true; } } Now, let's say I have PreferenceCategory variable created, and I want...

Is there any way in C# to enforce operator overloading in derived classes?

I need to define an Interface which has to enforce certain operator overloading to the types which implements it. There doesn't seem an obvious way to do it since operator overloading has to be done using static methods in class. Is there any way to achieve the same effect (using abstract classes or anything else)? ...

How to create pool allocator for abstract base class in C++?

Have run into a bug with glibc's malloc(): http://sourceware.org/bugzilla/show_bug.cgi?id=4349 and am thinking a work around for now until updating to later version of glibc is to do pooled allocation for small objects that have many instances coming and going. The small objects are all derived from an abstract base class. I'd like to ...

Is there no way to upcast into an abstract class and not modify it each time a class is derived from it?

#include<iostream> using namespace std; class Abs { public: virtual void hi()=0; }; class B:public Abs { public: void hi() {cout<<"B Hi"<<endl;} void bye() {cout<<"B Bye"<<endl;} }; class C:public Abs { public: void hi() {cout<<"C Hi"<<endl;} void sayonara() {cout<<"C Sayo...

Statics Properties in abstract clases

Could anybody explain why static property is null? class Program { static void Main(string[] args) { string s = Cc.P1; // is null } } public class Cc : Ca { static Cc() { P1 = "Test"; } } public abstract class Ca { public static string P1 { get; protected set; } }...

Code is not working when i use abstract keyword in middle class

i have got below code which is working fine: public abstract class Beverage { public string description = "Unknown beverage"; public virtual string getDescription() { return description; } public abstract double cost(); } public abstract class condimentDecorator : Beverage { // public abstract string g...

what is the size of an abstract class and why can't we create objects of an abstract class?

what is the size of an abstract class and why can't we create objects of an abstract class? ...

How do I fix this Java Generics wildcard/abstract ambiguity problem?

The code below is a simplified version of the pattern my project is using. The standard pattern we use is to have a Writer for each object type. For the subtypes of one abstract type (in this example Animal), I'd like an enum to serve as a lookup for the correct writer. abstract class Writer<T> { abstract void write(T value); } a...

C# abstract base class for common columns in LINQ

This is what I have so far using System; using System.Collections.Generic; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Linq; using System.Text; namespace Firelight.Business { public interface IBaseEntity<K> { K Id { get; } } /// <summary> /// Base business database connection object...

Trouble with inheritance of operator= in C++

I'm having trouble with the inheritance of operator=. Why doesn't this code work, and what is the best way to fix it? #include <iostream> class A { public: A & operator=(const A & a) { x = a.x; return *this; } bool operator==(const A & a) { return x == a.x; } virtual int get() = 0; ...

abstract method of a set length array in java?

Hi, i am trying to create a abstract array method that specify's that this abstract object of an array can only hold 3 items. Now i have tried doing something like this public abstract BaseAdapter[3] adapters(); but it complains with an error that it cant be done this way. is their another way or do i need to just do public abstract Ba...

Override equal's and hashCode for abstract super class

Consider the sample code given below: Abstract Name public abstract class Name { private String name; public Name(String name) { this.name=name; } public String toString() { return name; } public String getName() { return name; } } FirstName public class FirstName extends Name { FirstName(String name) { super(...