Questions tagged [abstract]

abstract is a keyword shared by a multitude of object-oriented programming languages. Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic and have to be extended. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

abstract is a keyword shared by a multitude of object-oriented programming languages.

Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

The exact meaning of abstract depends on the programming languages in question, some of them being: Java, C#, php, C++, Delphi Pascal. Similar logic can also be implemented using different keywords in other languages ( for example, Oracle PL/SQL allows to create abstract classes and methods by declaring them NOT FINAL)

The power of abstract methods and classes is widely used by design patterns.

2521 questions
0
votes
2 answers

How can I make a private child function visible to the base class?

Assume that I have the following classes with a generic interface: public class MyClass_1 : IGenericInterface { public void foo() { bar(); } void bar() { ... } } public class MyClass_2 :…
RadioMan85
  • 337
  • 1
  • 11
0
votes
1 answer

Referencing method from abstract class

START OF INSTRUCTIONS If there is a game piece on the clicked square (clickedSquare.getPiece()!= null) Make sure the game piece belongs to the current player. You can get the owning player by calling the getPlayerType() method on the…
Meezy98
  • 3
  • 3
0
votes
0 answers

C# How do I get an instance of a derived class inside abstract class that it is derived from?

I have my code posted below and it gives this error- cannot convert from 'BaseClass' to 'DerivedFromBaseClass' But i understand why I get this error. because 'this' is BaseClass . it's not not DerivedFromBaseClass I can get the type for the class…
0
votes
0 answers

Interfaces on c++

I wanted to ask you which version is better to use. I am talking about de inheritance of the pawn. in the first example i have a double inheritance, in the second i have just one and i want to know which version is better to use. Look at the class…
palalele
  • 21
  • 6
0
votes
2 answers

Instance variables inside an Abstract Class ****Eclipse malfunctioned, this question is pointless****

So in a challenge in class, we had to use a public abstract Class Cycle as the parent class and create subclasses off of it. I used Unicycle Class as an example. My professor refuses to let me put Color color as protected. He wants it private. He…
PresFelber
  • 61
  • 6
0
votes
2 answers

C# error cs0534: does not implement abstract member get - although I do

I am new to c#. I got an interface that I need to implement, including this line in the interface: public abstract IEnumerable AllCards { get; } In my implementation I have this code: public IEnumerable AllCards { …
moran
  • 1
0
votes
1 answer

In Java, how to specify generic type?

I am trying to create a generic method that defines a search. The search will receive the field name and the value to be searched as input parameters, not the object itself. The problem is that I am getting the following errors in the 'return'…
vuco
  • 161
  • 2
  • 6
0
votes
1 answer

How to define a function that will print an entire column?

I am trying to create a function get_data which takes in a file name and column number, and returns the numbers (as floats) found in the column. This is my code. def get_data(filename, columnnumber): open(filename, 'r').readlines() …
0
votes
1 answer

How to implement hidden abstract method?

If the abstract method was hidden by previous abstract inheritance, how can I implement it in concrete class? I have no way to access it, only the access to the inheriting abstract method with same name. The system reports error even it's masked.…
oversea
  • 1
  • 1
0
votes
1 answer

Abstract Base Class create instance of derived class with Base class as type

I got a simple problem: I have a base class which is abstract, and I want to use it as type for a derived class. What I mean is this: class Rule { public: //Return value is equal to the count of consumned chars or -1 if the given chars are…
Reskareth
  • 47
  • 4
0
votes
0 answers

Trying to cope with the absence of abstract variables in Java

To summarize my problem: I'd like to write an abstract class called Player and have different non-abstract "role" classes extend it. So far so good. I'd also like every sub-class of Player to contain a variable that displays its individual name, and…
Robson
  • 23
  • 3
0
votes
2 answers

Can't errors related with instantiating / inheriting class be treated by try~catch statement?

I hope to run the below C# codes to practice usage of abstract / sealed classes : using System; abstract class Person // abstract : can be inherited but can't be instantiated { public Person() { Console.Write(this + " : "); …
Kimpro
  • 81
  • 2
  • 11
0
votes
0 answers

Insertion of abstract array element using templates

I'm working on a program to stack numbers independent from their type and print them. Everything works but unfortunately it seems the first array element comes out incorrectly. Expected output: 6 5 4 3 2 1 Actual output: 6 5 4 3 2 6 Does anybody…
pacours
  • 33
  • 6
0
votes
1 answer

Passing an object of a class to another class without importing?

I have classes called Logger and Error Handler in separate projects. These are each made into jar files which I can then use as libraries in various other projects. I now need to use the static functions from Logger class in the Error Handler…
0
votes
1 answer

Django: How to create a abstract field?

I would like to start using an abstract model for my application (based on a django-accounting app). How should I create my field on the views.py. I guess I will also need to change my view file when creating a new field...Can I still create the…
Steve
  • 31
  • 12
1 2 3
99
100