0
голосов
5ответов
600 просмотров

Using an abstract class to implement a stack of elements of the derived class

I have to do this for a basic C++ lecture at my university, so just to be clear: i would have used the STL if i was allowed to. The Problem: I have a class named "shape3d" from which i derived the classes "cube" and "sphere". Now i have to implement "shape3d_stack", which is meant be able of hol...

0
голосов
3ответов
1614 просмотров

Why is my Polymorphic Parent class calling the Subclass Method from within itself?

Heres the code I've made up so far. Its fully functional and the only gripe I have with it is that my output for Weekly and Annual pay is always weekly...I'm at a loss as to how to get this from within either toString method. public class PolyEmployees { public static void main(String[] arg...

0
голосов
8ответов
992 просмотров

Accessing a method from a templated derived class without using virtual functions in c++?

How do I get around this? I clearly cannot make the value() method virtual as I won't know what type it is beforehand, and may not know this when accessing the method from b: class Base { public: Base() { } virtual ~Base() { } private: int m_anotherVariable; }; template <typename...

0
голосов
2ответов
224 просмотров

Why is my nest class being seen as abstract?

I have an abstract base class which contains a private nested implementation. visual c++ is giving me the following error when I try to instantiate the non-abstract nested implementation: error C2259: 'node::empty_node' : cannot instantiate abstract class (line 32) as far as I can tell, I've o...

31
голосов
4ответов
26113 просмотров

AS3 - Abstract Classes

How can I make an abstract class in AS3 nicely? I've tried this: public class AnAbstractClass { public function toBeImplemented():void { throw new NotImplementedError(); // I've created this error } } public class AnConcreteClass extends AnAbstractClass { override publi...

9
голосов
2ответов
1513 просмотров

in PHP, when should I use static methods vs abstract classes?

I'm under the interpretation that if I need to access a method statically, I should make the class abstract only if I'll never need it instantiated. Is that true?

2
голосов
2ответов
265 просмотров

Java Puzzler - Can anyone explain this behavior?

abstract class AbstractBase { abstract void print(); AbstractBase() { // Note that this call will get mapped to the most derived class's method print(); } } class DerivedClass extends AbstractBase { int value = 1; @Override void print() { System....

17
голосов
11ответов
28735 просмотров

What are some practical examples of abstract classes in java?

When and why should abstract classes be used? I would like to see some practical examples of their uses. Also, what is the difference between abstract classes and interfaces?

6
голосов
1ответов
1624 просмотров

Does an abstract class work with StructureMap like an interface does?

I am a big fan of StructureMap and use it in just about everything I do. I have only ever used it with interfaces though. I was wondering if anyone had any experience using with abstract classes? or...does it not support that type of wiring? If you got this to work can you post an example? T...

15
голосов
4ответов
15168 просмотров

Copy constructor: deep copying an abstract class

Suppose I have the following (simplified case): class Color; class IColor { public: virtual Color getValue(const float u, const float v) const = 0; }; class Color : public IColor { public: float r,g,b; Color(float ar, float ag, float ab) : r(ar), g(ag), b(ab) {} Color getValue...

1
голосов
1ответов
727 просмотров

How to override the type of a member in abstract class in child class

I have following code: public abstract class TestProperty { public abstract Object PropertyValue { get; set; } } public class StringProperty: TestProperty { public override string PropertyValue {get;set} } which generate compilation error, I wonder should I have to use generic type in...

1
голосов
3ответов
452 просмотров

abstract class with published Api but default access constructor

In the MIDP api there is a public abstract class Layer, this class has a javadoc published however it doesn't show a constructor in the javadoc. In the same api there are two other classes Sprite and TiledLayer. public class Sprite extends Layer public class TiledLayer extends Layer All thes...

11
голосов
2ответов
60416 просмотров

Call a class inside another class in PHP

Hey there I'm wondering how this is done as when I try the following code inside a function of a class it produces some php error which I can't catch public $tasks; $this->tasks = new tasks($this); $this->tasks->test(); I don't know why the initiation of the class requires $this as a ...

1
голосов
4ответов
2423 просмотров

Refactoring abstract Java class with many child classes

I'm looking for ideas on the best way to refactor this scenario (better design, minimal effort). Starting from the following example abstract class (actual has many more fields, methods and abstract methods) : abstract class Car { private int manufactureYear; // ... many more fields tha...

5
голосов
3ответов
4360 просмотров

model an abstract base class and subclasses in a database

I have 4 subclasses: Video, Image, Note, and Form. Each one contains different types of data. For example, the Image class contains a path to the image file on disk and image properties, and the Form class contains the form field values. The common element between each item, however, is the GPS c...

0
голосов
2ответов
226 просмотров

What is the best way to store and instantiate list of classes in C++ without using STL?

I have a code similar to the following: class News { public: virtual void get() = 0; } class Cnn : News { void get () {...} } class Msnbc : News { void get () {...} } class Bbc : News { void get () {...} } main () { News * news = new Cnn; news->get () News * news = new Msnbc;...

8
голосов
4ответов
7903 просмотров

Abstract class> mandatory constructor for child classes

Possible Duplicate: Why can’t I create an abstract constructor on an abstract C# class? How can I write one abstract class that tells that is mandatory for the child class to have one constructor? Something like this: public abstract class FatherClass { public **<ChildConstru...

2
голосов
6ответов
841 просмотров

Should we need to differentiate between Interface class and abstract class, in terms of naming convention?

Is that important to differentiate between Abstract class and interface class? Abstract class is merely an interface class, with some concrete methods. If the abstract class shares the same prefix "I" with Interface class, we can easily upgrade our interface class to abstract class, by introduc...

2
голосов
5ответов
8657 просмотров

Java abstract modifier

Can the abstract modifier appear before a class, a method or a variable?

1
голосов
4ответов
986 просмотров

Public class with internal abstract member

We use DevExpress and with today release came a weird change to one of their printing class. The class is named ClosedShapeBase and it is used to print out shape in a report. The class itself is public, but some of its properties are protected internal abstract, like public abstract class Clos...

5
голосов
3ответов
6636 просмотров

How to Implement a Base Class with a Method and yet force the Derived Class to Override it?

Having something like this this : public abstract class AAA { protected abstract virtual string ToString() // Error { // Base Stuff } } public abstract class BBB : AAA { public override string ToString() { // Use base.ToString(); // More Stuff } } I read another pos...

276
голосов
14ответов
197508 просмотров

Abstract class in Java

What is an "abstract class" in Java?

10
голосов
3ответов
4213 просмотров

Using a Windows Form as an abstract class - which pattern to use?

I'm struggling with a situation that I come up again time and time again but I am not sure whether the way that I am doing things is wrong or whether I could be doing things in a different way. An Example: I have a Windows Form that has a DataGridView with some private methods to perform valida...

7
голосов
2ответов
6294 просмотров

Unresolved External (abstract class constructor/destructor)

So, I have an abstract class Panel and an implementation of it MyPanel. They look similar to this: class Panel : public QWidget { public: Panel(QWidget* parent = 0) = 0; virtual ~Panel() = 0; // but wait, there's more!! }; class MyPanel : public Panel { public: MyPanel(QWidget* parent =...

5
голосов
12ответов
41947 просмотров

Can an abstract class have a final method?

Can an abstract class have a final method in Java?

2
голосов
1ответов
460 просмотров

C++/CLI workaround for implementing a C++ interface

Micropather requires users implement their abstract class "Graph" in order to use the library. What's a good way to do this from C++/CLI so I can use Micropather in .NET? There are only two methods to implement: virtual float LeastCostEstimate( void* stateStart, void* stateEnd ) = 0; virtual vo...

1
голосов
2ответов
297 просмотров

What should the accessablity of Fields in a Abstract Class be?

To put it simply as an example, public abstract class AbstractFellow { protected Thing buddy; .... public class ConcreteFellow extends AbstractFellow { public void someMethod() { buddy.doSomething(); //OR buddy = somethingElse; //OR so...

4
голосов
3ответов
6803 просмотров

Using abstract class as a template type

I'm still pretty new to c++ (coming over from java). I have a stl list of type Actor. When Actor only contained "real" methods there was no problem. I now want to extend this class to several classes, and have a need to change some methods to be abstract, since they don't make sense as concrete a...

1
голосов
4ответов
530 просмотров

c# Generics help - how to pass params to new T()

Possible Duplicate: Create instance of generic type? How can I pass a param to a generic contstructor? public class Payment<T> where T: HostFunctionContext, IClaimPayment, new() { public IResultEntity Display(MyUser user, string claim, int? cert) { **HostFunct...

49
голосов
7ответов
23114 просмотров

Internal abstract class: how to hide usage outside assembly?

I have a common assembly/project that has an abstract base class, then several derived classes that I want to make public to other assemblies. I don't want the abstract base class to show up in these other assemblies in Intellisense, so I thought I'd make it internal, but I get this error: ...