Skip to main content

Questions tagged [abstract-class]

An abstract class is a class that cannot be instantiated. They are generally meant to be extended/subclasses and generally have "abstract methods" that must be implement by subclasses.

Filter by
Sorted by
Tagged with
5 votes
4 answers
3k views

I have seen many frameworks and modules and their standard they follow is like this UserInterface which have some predefined methods AbstractUserClass which implements userInterface Then ...
user26's user avatar
  • 201
2 votes
2 answers
1k views

Sometimes I read in observer-pattern descriptions, to make the constructor of a observer base class protected so the class will be abstract. but by making the constructor public (if even one is ...
itwasntpete's user avatar
1 vote
1 answer
1k views

I have a decision to make and I am wondering what would be the better solution. I am refactoring an older application and intend to really get into the nuts and bolts of it. There are 8 report types ...
Lotok's user avatar
  • 1,819
3 votes
2 answers
10k views

I wonder if I should write a database class for my application, and if so, how to accomplish it? Over there on SO, a guy mentioned it should be written as an abstract class. However, I can't ...
Wottensprels's user avatar
8 votes
3 answers
3k views

I have an abstract class A which declares an abstract method doStuff. Currently there are many classes that inherit from A and implement doStuff. The class' instances are initialized at run-time ...
Scis's user avatar
  • 191
10 votes
6 answers
11k views

Let's say we have an abstract class and let this class has only abstract methods. Is this abstract class different from an interface that has same methods only? What I am looking to know is if there ...
yfklon's user avatar
  • 1,772
50 votes
4 answers
60k views

Can anyone explain in detail, how exactly the virtual table works and what pointers are associated when virtual functions are called. If they are actually slower, can you show the time that the ...
MdT's user avatar
  • 619
2 votes
2 answers
994 views

So I understand the importance of Polymorphism, including how vital it is. But something I don't quite understand is what about the Constructor and any inherited Class the initial Base Class may have....
Greg's user avatar
  • 248
15 votes
3 answers
11k views

Is there a difference between public class A extends AbstractB implements C {...} versus... public class A extends AbstractB {...} abstract class AbstractB implements C {...} I understand that in ...
c_maker's user avatar
  • 8,310
5 votes
6 answers
9k views

I got several explanations but so far I'm not able to understand that what are the abstract classes and methods in Java. Some said it has to do something with the security of the program, other said ...
Umer Hassan's user avatar
4 votes
2 answers
2k views

I'm trying to follow LSP in practical programming. And I wonder if different constructors of subclasses violate it. It would be great to hear an explanation instead of just yes/no. Thanks much! P.S. ...
Kolyunya's user avatar
  • 975
23 votes
6 answers
17k views

Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between abstract classes and interfaces the more confused I become. So far, ...
user66662's user avatar
  • 309
6 votes
2 answers
889 views

I'm learning the 23 design patterns of the GoF. I think I've found a way to understand and simplify how the Abstract Factory works but I would like to know if this is a correct assumption or if I am ...
Chobeat's user avatar
  • 161
6 votes
4 answers
16k views

Hello fellow programmers, I am reading a book on C# and the author is comparing Abstract classes and Interfaces. He claims that if you have the following "abstract class:" abstract class ...
RealityDysfunction's user avatar
13 votes
4 answers
2k views

According to Herb Sutter one should prefer abstract interfaces (all pure virtual functions) to abstract classes in C++ to decouple the implementation as far as possible. While I personally find this ...
Martin's user avatar
  • 273
5 votes
3 answers
1k views

I have an abstract class which has all abstract methods except one which constructs objects of the subclasses. Now my mentor asked me to move this abstract class to an interface. Having an interface ...
nischayn22's user avatar
12 votes
7 answers
17k views

I am studying OOP in C++ and, even though I am aware of the definitions of these 3 concepts, I cannot really realize when or how to use it. Let's use this class for the example: class Person{ ...
appoll's user avatar
  • 353
12 votes
5 answers
10k views

I recently had to update an abstract base class on some OSS that I was using so that it was more testable by making them virtual (I could not use an interface as it combined two). This got me thinking ...
Justin Pihony's user avatar
11 votes
3 answers
21k views

Often times it's a good idea to have an abstract base class to isolate the interface of the object. The problem is that copy construction, IMHO, is pretty much broken by default in C++, with copy ...
Coder's user avatar
  • 6,978
8 votes
4 answers
14k views

I have quite a bit of Java code that I'm re-working to be re-used. The problem is that there are many pieces that are project specific so there are ends up being a higher level of coupling between ...
Tyler's user avatar
  • 789
0 votes
2 answers
5k views

Possible Duplicate: When to use abstract classes instead of interfaces and extension methods in C#? When I read and looked at codes using Abstract classes, I was able to justify it because it ...
javastudent's user avatar
2 votes
6 answers
907 views

I have two classes (named MyFoo1 and MyFoo2) that share some common functionality. So far, it does not seem like I need any polymorphic inheritance but, at this point, I am considering the following ...
palm snow's user avatar
  • 139
20 votes
2 answers
6k views

If throwing System.Exception is considered so bad, why wasn't Exception made abstract in the first place? That way, it would not be possible to call: throw new Exception("Error occurred."); This ...
marco-fiset's user avatar
  • 8,801
1 vote
1 answer
626 views

I'm doing a small assignment in C++ where I have to use concepts like virtual functions and inheritance in a domain of my choice. I'm implementing the prototype for a package manager in Linux. I have ...
nikhil's user avatar
  • 671
15 votes
6 answers
19k views

I was thinking about that, and I had some doubts. When I declare an interface, for example: public interface MyInterface { public void method1(); public void method2(); } Could these ...
rogcg's user avatar
  • 385
43 votes
9 answers
117k views

I know the syntax, rules applied to abstract class and I want know usage of an abstract class Abstract class can not be instantiated directly but can be extended by other class What is the ...
Vaibhav Jani's user avatar
72 votes
7 answers
82k views

"Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived ...
Gulshan's user avatar
  • 9,542