Skip to main content

Questions tagged [inheritance]

One of the four pillars of object-oriented programming (OOP), inheritance establishes a "is-a" relationship between objects. For example, a "Cat" object can be treated in code as any other "Animal" object because a "Cat" is-a "Animal".

5 votes
2 answers
255 views

ostream that counts and discards the characters written to it

The code below implements a class, CountingOStream, whose job is to count the number of characters written to it while also discarding those characters and ...
Scott McPeak's user avatar
2 votes
0 answers
57 views

Classes for Config and logical operators

I have a spring cloud gateway application with this yml structure for request validation: ...
Q2Dev's user avatar
  • 21
2 votes
0 answers
138 views

"Better" enumeration for C#

I've been looking to have "smarter" or "better" enum functionality in C#. There are a few GitHub/NuGet projects out there, but they seem to target newer versions of .NET and I ...
Jesse C. Slicer's user avatar
1 vote
1 answer
206 views

Python3 currency abstract class (without the permission to be instantiated directly)

I'm a newbie python developer who accidentally studied the concept of Abstract classes and I found it pretty much helpful to implement due to the SOLID principles. At the very moment of testing and ...
KhodeNima's user avatar
  • 399
0 votes
1 answer
54 views

Python 3.10+: an exploration of meta classes and subclasses through the lens of metric (SI) prefixes with subclass-able units and changeable bases

Problem Statement From the National Institute of Standards and Technology's Office of Weights and Measures, one can find a handy list of all the metric prefixes: e.g. Purpose Name Symbol Factor Name ...
SumNeuron's user avatar
  • 271
0 votes
1 answer
178 views

Calling the base method from overriden method to add some functionality

I have a small Linked list program which I created for just brushing up the concepts. Following is my Node class ...
Jyothish Bhaskaran's user avatar
1 vote
2 answers
48 views

Extend native `Array` instances

I need/want to extend created array instance, to add extra methods that i see as useful. class.labels.js ...
Marc's user avatar
  • 153
4 votes
1 answer
396 views

Abstract base class for binary serialization

Ensuring that some logic is always being run before the user's overriding methods. I'm writing a library and I have some abstract classes that can be binary serialized (and users can subclass them and ...
Saturn's user avatar
  • 409
2 votes
1 answer
488 views

Statically allocated buffer using templates

I want to have some classes that would contain arrays of different sizes. I want this to be statically allocated because it is intended for an embedded system. The only good solution I can think of is ...
hellothere's user avatar
2 votes
1 answer
72 views

Reversing a type converter with minimal redundancies

The objective is to implement the reversed version of StringToDoubleConverter but without writing too many redundancies. I love DRY (Don't Repeat Yourself) design ...
D G's user avatar
  • 135
0 votes
1 answer
452 views

Class that counts its instances

I'd love some feedback on the C++ base class shown below. It's basically a toy problem for a fake video game where the monsters that you have to avoid will all be sub-classed from the class shown ...
tarstevs's user avatar
2 votes
0 answers
113 views

A Python base class for a family of Postgres server manager classes

I'm working on a repo the purpose of which is to create and manage a local PostGIS server. (PostGIS is a bit niche, but it boils down to a few extra spatial data types and built-in SQL function. With ...
Tom Hosker's user avatar
6 votes
2 answers
982 views

Classes representing 2D points and pixels

How can I improve this code or make it tidier? ...
user366312's user avatar
0 votes
1 answer
200 views

C++20 Wrapper class for an unsigned integer type and a templated derived class that codes modular arithmetic type

The context is a library to represent numbers (in this case integers) by wheighted position by radix powers for every radix R, passed as template argument. These derived types are digits of radix R, ...
Earendil's user avatar
2 votes
1 answer
1k views

Java implementation of Employee class hierarchy

We were tasked to do this assignment where there is the base class employee and two derived class part-time and full-time employees. Here is what I came up with: ...
kairodesu's user avatar

15 30 50 per page
1
2 3 4 5
21