Kotlin Inheritance

I'm currently learning to split my messy code into DDD (note, learning) paradigm. The entities (IEntity, IUser) is domain layer is made up of interface, which then implemented at the Data layer (BaseEntity, User). Access to data is through the reposi...
more »

2017-05-17 03:05 (2) Answers

Make a class that cannot be instantiated?

Suppose that I have a class Bar. I want to use Bar uniquely as a base class, e.g.: class Foo : public Bar I want to disallow Bar from being able to be instantiated. In other words, I want Bar object; to be an error. Is this possible to do? ...
more »

2017-05-15 00:05 (1) Answers

Common method uses unknown object type java

I am writing some java code and I am unsure of what structure I should use. I have different classes that each contain a populate method which receives a line of text from a text file. The contents of the text file are specific to the class. I need ...
more »

2017-05-12 19:05 (1) Answers

How to call abstract class method

I have an interface called Hospital.java public interface Hospital { public void operate(); public void doScan(); public void doVaccination(); } I have an abstract class called StreetHospital.java public abstract class StreetHospital ...
more »

2017-05-10 07:05 (12) Answers

Inheriting child-specific method from parent

I don't know if this is at all possible, but I was thinking of something in Java: If I have an abstract parent class, I can do this: public ParentClass add(ParentClass a, ParentClass b); If ParentClass then has a child and I want to override this...
more »

2017-05-09 10:05 (3) Answers

Iterate over different objects

I would like to iterate over different objects that all inhereit from the same superclass. That means I have a superclass like this: class fruit { public: fruit() { } }; And I have subclasses like this, which define the objec...
more »

2017-05-02 20:05 (1) Answers

No matcing function to call to class::class

Im new to c++ and am working on a pacman prototype. While trying to grasp the concept of polymorphism i came accross this problem. Every time i try to create a constructor or an object for Ghost and ScaredGhost classes i end up with the No matcing fu...
more »

2017-04-27 01:04 (1) Answers

How do I add classes in C++?

**Below is my header file. In my main.cpp file I need to make three instances of Student and add them to the Course object. How is this done? I can't seem to find the answer in any textbook or online. Then I need to Instantiate at least one Teacher o...
more »

2017-04-26 20:04 (3) Answers

Class inheritance: generic extends generic

Let's say I have simple class public class MyObject { } And the handler interface for processing the child classes of MyObject public interface MyObjectHandler<V extends MyObject>{ List<V> handle(List<V> objects); } Suppo...
more »

2017-04-25 15:04 (3) Answers

Java inheritance fields

I am not able to understand the following output. I don't know why the output is 10, I think the line A a = new B() creates a new instance of class B, I think the result should be 20 class A { int i = 10; } class B extends A { int i = 20; ...
more »

2017-04-24 05:04 (5) Answers