Modifying variables in subclass instances

I've become hopelessly addicted to Screeps recently, and I refactored some code to make a task-based implementation. Tasks are things like "walk to and then harvest until you are at full capacity" and are based off of a single base task template writ...
more »

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

Error Building Due to Strange Inheritance

While working on a project recently, I came across an error which prevented the project from building, kept giving pop-ups to tell me it wasn't building, and also prevented me from running the project (despite the fact that Eclipse wasn't showing me ...
more »

2017-02-19 18:02 (0) Answers

Nested classes in different files with inheritance

So I made a single program with one class containing a number of classes, but I thought it would be more organised to split it up into multiple programs, one for each subclass. Would this be a better way to organise my code, and does this affect perf...
more »

2017-02-17 21:02 (2) Answers

How does the Decorator pattern chain method calls?

I read one example of Decorator Design Pattern. I understood that this design pattern modifies the behaviour of one particular instance dynamically. The example which I have given below is also understandable. The point which I did not understand is ...
more »

2017-02-13 15:02 (4) Answers

Virtual Functions Doubts

I have this simple code to test VF class A { public: virtual const char Get (){return 'A';} }; class B : public A { public: const char Get (){return 'B';} }; class C : public B { public: const char Get (){return 'C';} }; class D : public C { publ...
more »

2017-02-12 06:02 (1) Answers

Accessing child class property

I have 2 classes which are inherited in this manner public class PartsParent { } public class PartsCar : PartsParent { public int WheelRadius { get; set; } public int Price { get; set; } } public class PartsBike : PartsParent { ...
more »

2017-02-09 06:02 (4) Answers

Numpy functions clobber my inherited datatype

Say I have a class ndarray_plus that inherits from numpy.ndarray and adds some extra functionality. Sometimes I pass it to numpy functions like np.sum and get back an object of type ndarray_plus, as expected. Other times, numpy functions that I pass...
more »

2017-02-09 02:02 (1) Answers

Interfaces and Inheritance with generics in C#

In order to use dependency injection in .NET Core, we've built a bunch of repository interfaces for our controllers to use for database interactions. We have a EntityBase class that has some methods in it, and our generic repository interface uses t...
more »

2017-02-08 19:02 (2) Answers

Inheritance class and constructor

I tried to create program that will have derived class Kafic where it will have same info as Lokal but I could add function sale(); where I would have strings with some info about sales in that coffee shop, I am having problem with inheritance and wh...
more »

2017-02-06 13:02 (1) Answers